コード例 #1
0
        void AccountSubGroupsManage_Members(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_group_subgroup_members");

            long id = core.Functions.RequestLong("id", 0);

            if (id <= 0)
            {
                return;
            }

            try
            {
                subUserGroup = new SubUserGroup(core, id);
            }
            catch (InvalidSubGroupException)
            {
                return;
            }

            if (subUserGroup.CanEditItem())
            {
                List<SubGroupMember> leaders = subUserGroup.GetLeaders();
                List<SubGroupMember> awaiting = subUserGroup.GetMembersWaitingApproval();
                List<SubGroupMember> members = subUserGroup.GetMembers(core.TopLevelPageNumber, 25);

                UserSelectBox newUserSelectBox = new UserSelectBox(core, "usernames");
                newUserSelectBox.SelectMultiple = false;
                //Form.AddFormField(newUserSelectBox);

                YesNoList makeLeaderYesNoList = new YesNoList(core, "make-leader");
                makeLeaderYesNoList.SelectedKey = "no";
                //Form.AddFormField(makeLeaderYesNoList);

                YesNoList makeDefaultYesNoList = new YesNoList(core, "make-default");
                makeDefaultYesNoList.SelectedKey = "no";
                //Form.AddFormField(makeDefaultYesNoList);

                template.Parse("SUBGROUP_DISPLAY_NAME", subUserGroup.DisplayName);
                template.Parse("S_USERNAMES", newUserSelectBox);
                template.Parse("S_MAKE_LEADER", makeLeaderYesNoList);
                template.Parse("S_MAKE_DEFAULT_GROUP", makeDefaultYesNoList);
                template.Parse("S_GROUP_ID", subUserGroup.Id.ToString());

                foreach (SubGroupMember member in leaders)
                {
                    CheckBox memberCheckBox = new CheckBox("check[" + member.Id.ToString() + "]");

                    VariableCollection memberVariableCollection = template.CreateChild("leader_list");
                    memberVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                    memberVariableCollection.Parse("JOINED_DATE", core.Tz.DateTimeToDateString(member.GetJoinedDate(core.Tz)));
                    memberVariableCollection.Parse("S_MARK", memberCheckBox);

                    if (member.IsDefaultGroup)
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("YES"));
                    }
                    else
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("NO"));
                    }
                }

                foreach (SubGroupMember member in awaiting)
                {
                    CheckBox memberCheckBox = new CheckBox("check[" + member.Id.ToString() + "]");

                    VariableCollection memberVariableCollection = template.CreateChild("awaiting_list");
                    memberVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                    memberVariableCollection.Parse("JOINED_DATE", core.Tz.DateTimeToDateString(member.GetJoinedDate(core.Tz)));
                    memberVariableCollection.Parse("S_MARK", memberCheckBox);

                    if (member.IsDefaultGroup)
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("YES"));
                    }
                    else
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("NO"));
                    }
                }

                foreach (SubGroupMember member in members)
                {
                    CheckBox memberCheckBox = new CheckBox("check[" + member.Id.ToString() + "]");

                    VariableCollection memberVariableCollection = template.CreateChild("member_list");
                    memberVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                    memberVariableCollection.Parse("JOINED_DATE", core.Tz.DateTimeToDateString(member.GetJoinedDate(core.Tz)));
                    memberVariableCollection.Parse("S_MARK", memberCheckBox);

                    if (member.IsDefaultGroup)
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("YES"));
                    }
                    else
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("NO"));
                    }
                }

            }
            else
            {
                return;
            }

            Save(AccountSubGroupsManage_Members_AddNew);
        }
コード例 #2
0
ファイル: SubGroup.cs プロジェクト: smithydll/boxsocial
        public static void Show(object sender, ShowPageEventArgs e)
        {
            e.Template.SetTemplate("Groups", "viewsubgroup");

            SubUserGroup subgroup;

            try
            {
                subgroup = new SubUserGroup(e.Core, e.Core.PagePathParts[1].Value);
            }
            catch (InvalidSubGroupException)
            {
                e.Core.Functions.Generate404();
                return;
            }

            e.Template.Parse("U_FILTER_ALL", subgroup.Uri);
            e.Template.Parse("U_FILTER_BEGINS_A", subgroup.GetUri("a"));
            e.Template.Parse("U_FILTER_BEGINS_B", subgroup.GetUri("b"));
            e.Template.Parse("U_FILTER_BEGINS_C", subgroup.GetUri("c"));
            e.Template.Parse("U_FILTER_BEGINS_D", subgroup.GetUri("d"));
            e.Template.Parse("U_FILTER_BEGINS_E", subgroup.GetUri("e"));
            e.Template.Parse("U_FILTER_BEGINS_F", subgroup.GetUri("f"));
            e.Template.Parse("U_FILTER_BEGINS_G", subgroup.GetUri("g"));
            e.Template.Parse("U_FILTER_BEGINS_H", subgroup.GetUri("h"));
            e.Template.Parse("U_FILTER_BEGINS_I", subgroup.GetUri("i"));
            e.Template.Parse("U_FILTER_BEGINS_J", subgroup.GetUri("j"));
            e.Template.Parse("U_FILTER_BEGINS_K", subgroup.GetUri("k"));
            e.Template.Parse("U_FILTER_BEGINS_L", subgroup.GetUri("l"));
            e.Template.Parse("U_FILTER_BEGINS_M", subgroup.GetUri("m"));
            e.Template.Parse("U_FILTER_BEGINS_N", subgroup.GetUri("n"));
            e.Template.Parse("U_FILTER_BEGINS_O", subgroup.GetUri("o"));
            e.Template.Parse("U_FILTER_BEGINS_P", subgroup.GetUri("p"));
            e.Template.Parse("U_FILTER_BEGINS_Q", subgroup.GetUri("q"));
            e.Template.Parse("U_FILTER_BEGINS_R", subgroup.GetUri("r"));
            e.Template.Parse("U_FILTER_BEGINS_S", subgroup.GetUri("s"));
            e.Template.Parse("U_FILTER_BEGINS_T", subgroup.GetUri("t"));
            e.Template.Parse("U_FILTER_BEGINS_U", subgroup.GetUri("u"));
            e.Template.Parse("U_FILTER_BEGINS_V", subgroup.GetUri("v"));
            e.Template.Parse("U_FILTER_BEGINS_W", subgroup.GetUri("w"));
            e.Template.Parse("U_FILTER_BEGINS_X", subgroup.GetUri("x"));
            e.Template.Parse("U_FILTER_BEGINS_Y", subgroup.GetUri("y"));
            e.Template.Parse("U_FILTER_BEGINS_Z", subgroup.GetUri("z"));

            List<SubGroupMember> awaitingApproval = subgroup.GetMembersWaitingApproval();

            foreach (SubGroupMember member in awaitingApproval)
            {
                VariableCollection approvalVariableCollection = e.Core.Template.CreateChild("approval_list");

                approvalVariableCollection.Parse("U_MEMBER", member.Uri);
                approvalVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                approvalVariableCollection.Parse("LOCATION", member.Profile.Country);
                approvalVariableCollection.Parse("JOINED", e.Core.Tz.DateTimeToDateString(member.GetJoinedDate(e.Core.Tz)));
            }

            if (awaitingApproval.Count > 0)
            {
                e.Core.Template.Parse("IS_WAITING_APPROVAL", "TRUE");
            }

            List<SubGroupMember> leaders = subgroup.GetLeaders();

            foreach (SubGroupMember member in leaders)
            {
                VariableCollection leaderVariableCollection = e.Core.Template.CreateChild("leader_list");

                leaderVariableCollection.Parse("U_MEMBER", member.Uri);
                leaderVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                leaderVariableCollection.Parse("LOCATION", member.Profile.Country);
                leaderVariableCollection.Parse("JOINED", e.Core.Tz.DateTimeToDateString(member.GetJoinedDate(e.Core.Tz)));
            }

            List<SubGroupMember> members = subgroup.GetMembers(e.Page.TopLevelPageNumber, 20, e.Core.Functions.GetFilter());
            // TODO, cache
            long memberCount = members.Count; // e.Db.LastQueryRows;

            foreach (SubGroupMember member in members)
            {
                VariableCollection memberVariableCollection = e.Core.Template.CreateChild("member_list");

                memberVariableCollection.Parse("U_MEMBER", member.Uri);
                memberVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                memberVariableCollection.Parse("LOCATION", member.Profile.Country);
                memberVariableCollection.Parse("JOINED", e.Core.Tz.DateTimeToDateString(member.GetJoinedDate(e.Core.Tz)));

                /*if (string.IsNullOrEmpty(member.UserThumbnail))
                {
                    memberVariableCollection.Parse("I_DISPLAY_PIC", string.Empty);
                }
                else
                {
                    Image displayPic = new Image("display-pic[" + member.Id.ToString() + "]", member.UserThumbnail);
                    memberVariableCollection.Parse("I_DISPLAY_PIC", displayPic);
                }*/
            }

            if (e.Core.Session.IsLoggedIn)
            {
                if (subgroup.IsSubGroupMember(e.Core.Session.LoggedInMember.ItemKey))
                {
                    if (!subgroup.IsSubGroupLeader(e.Core.Session.LoggedInMember))
                    {
                        e.Template.Parse("U_LEAVE", subgroup.LeaveUri);
                    }
                }
                else
                {
                    if (subgroup.SubGroupType == "OPEN" || subgroup.SubGroupType == "REQUEST")
                    {
                        e.Template.Parse("U_JOIN", subgroup.JoinUri);
                    }
                }
            }

            e.Core.Display.ParsePagination(subgroup.GetUri(e.Core.Functions.GetFilter()), e.Page.TopLevelPageNumber, (int)(Math.Ceiling(memberCount / 20.0)));
        }