Beispiel #1
0
        private void bindGroups()
        {
            preparePaginator();

            DataTable dtGroups = new DataTable("Groups");

            dtGroups.Columns.Add("GroupID");
            dtGroups.Columns.Add("Name");
            dtGroups.Columns.Add("Description");
            dtGroups.Columns.Add("IsVisibleLinkMore", typeof(bool));
            dtGroups.Columns.Add("DateCreated");
            dtGroups.Columns.Add("Approved");
            dtGroups.Columns.Add("AccessLevel");
            dtGroups.Columns.Add("Owner");
            dtGroups.Columns.Add("MemberType");
            dtGroups.Columns.Add("Pending");
            dtGroups.Columns.Add("MembersCount");

            Group[] groups = null;

            if (Results == null)
            {
                Results = new GroupSearchResults();

                if (GroupType == eGroupType.ByCategory)
                {
                    Results.Groups =
                            Group.Search(ViewedCategoryID, null, null, null, true, null, null, null, null, false, null,
                                         Group.eSortColumn.ActiveMembers);
                }
                else if (GroupType == eGroupType.MyGroups)
                {
                    Results.Groups = Group.SearchGroupsByUsername(username, Group.eSortColumn.ActiveMembers);
                }
                else if (GroupType == eGroupType.NewGroups)
                {
                    Results.Groups =
                        Group.Search(null, null, null, null, true, null, null, null, null, false,
                                     Config.Groups.NumberOfNewGroups, Group.eSortColumn.DateCreated);
                }

                if (Results.Groups.Length == 0)
                {
                    if (ShowPnlPendingActions)
                    {
                        lblError.Text = Lang.Trans("There are no pending invitations.");
                    }
                    else if (GroupType == eGroupType.MyGroups)
                    {
                        lblError.Text = Lang.Trans("You are not a member of any group.");
                    }
                    else if (GroupType == eGroupType.NewGroups)
                    {
                        lblError.Text = Lang.Trans("There are no new groups.");
                    }
                    else if (GroupType == eGroupType.ByCategory)
                    {
                        lblError.Text = Lang.Trans("There are no groups.");
                    }

                    PaginatorEnabled = false;
                    dlGroups.Visible = false;
                    pnlSearchParameters.Visible = false;
                    return;
                }
                else
                {
                    PaginatorEnabled = !ShowPnlPendingActions ? true : false;
                }

                CurrentPage = 1;
            }

            groups = !ShowPnlPendingActions ? Results.GetPage(CurrentPage, Config.Groups.GroupsPerPage) : Results.Get();

            if (groups != null && groups.Length > 0)
            {
                foreach (Group group in groups)
                {
                    if (group == null)
                        continue;

                    bool isVisibleLinkMore = false;
                    string MemberType = String.Empty;
                    string pending = String.Empty;
                    GroupMember groupMember = null;

                    if (FetchGroupMember)
                    {
                        groupMember = GroupMember.Fetch(group.ID, CurrentUserSession.Username);
                        if (groupMember != null)
                        {
                            MemberType = groupMember.Active
                                             ?
                                         "(" + Lang.Trans(groupMember.Type.ToString()) + ")"
                                             :
                                         "(" + Lang.Trans("Pending") + ")";
                        }

                        if (group.Owner == CurrentUserSession.Username)
                        {
                            MemberType = "(" + Lang.Trans("Owner") + ")";
                        }

                        if (!group.Approved)
                        {
                            pending = "(" + Lang.Trans("-- pending approval --") + ")"; 
                        }
                    }

                    if (ShowPnlPendingActions)
                    {
                        // if group member is not invited or is alreay invited
                        if (groupMember != null && (groupMember.InvitedBy == null || groupMember.Active))
                        {
                            continue;
                        }
                    }

                    string more = group.Description.Length > 200 ? "..." : String.Empty;
                    string accessLevel = String.Empty;
                    switch(group.AccessLevel){
                        case Group.eAccessLevel.Public:
                            accessLevel = Lang.Trans("Public Group");
                            break;
                        case Group.eAccessLevel.Moderated:
                            accessLevel = Lang.Trans("Moderated Group");
                            break;
                        case Group.eAccessLevel.Private:
                            accessLevel = Lang.Trans("Private Group");
                            break;
                    }

                    dtGroups.Rows.Add(new object[]
                                          {
                                              group.ID,
                                              Parsers.ProcessGroupName(group.Name),
                                              Parsers.ProcessGroupDescription(
                                                Parsers.ShortenString(group.Description, 200, 5),
                                                true) + more,
                                              isVisibleLinkMore = group.Description.Length > 200,
                                              group.DateCreated.Add(Config.Misc.TimeOffset).ToShortDateString(),
                                              group.Approved,
                                              accessLevel,
                                              group.Owner,
                                              MemberType,
                                              pending,
                                              group.ActiveMembers
                                          });
                }

                if (ShowPnlPendingActions && dtGroups.Rows.Count == 0)
                {
                    lblError.Text = Lang.Trans("There are no pending invitations.");
                }
            }

            dlGroups.Visible = dtGroups.Rows.Count > 0;
            dlGroups.DataSource = dtGroups;
            dlGroups.DataBind();
        }
Beispiel #2
0
        protected void btnSearchGroupByCategory_Click(object sender, EventArgs e)
        {
            LargeBoxStart1.Title = Lang.Trans("Groups");

            int[] groupIDs;

            groupIDs =
                Group.Search(ViewedCategoryID, null, null, null, true, null, null, null,
                             txtSearchGroupByCategory.Text.Trim(), cbSearchInDescriptionByCategory.Checked, null, Group.eSortColumn.Name);

            GroupSearchResults results = new GroupSearchResults();
            results.Groups = groupIDs;

            SearchResults1.Results = results;

            enableMenuLinks();

            mvGroups.SetActiveView(viewGroupSearchResults);
        }
        private void bindGroups()
        {
            preparePaginator();

            DataTable dtGroups = new DataTable("Groups");

            dtGroups.Columns.Add("GroupID", typeof(int));
            dtGroups.Columns.Add("Categories");
            dtGroups.Columns.Add("Name");
            dtGroups.Columns.Add("Description");
            dtGroups.Columns.Add("Approved");
            dtGroups.Columns.Add("AccessLevel");
            dtGroups.Columns.Add("Owner");
            dtGroups.Columns.Add("DateCreated");

            Group[] groups = null;

            if (Results == null)
            {
                Results = new GroupSearchResults();

                Results.Groups =
                        Group.Search(null, null, null, null, false, null, null, null, null, false, null,
                                     Group.eSortColumn.DateCreated);

                if (Results.Groups.Length == 0)
                {
                    MessageBox.Show(Lang.TransA("There are no groups waiting for approval!"), Misc.MessageType.Error);
                    PaginatorEnabled = false;
                    dgPendingApproval.Visible = false;
                    lblGroupsPerPage.Visible = false;
                    ddGroupsPerPage.Visible = false;
                    return;
                }

                CurrentPage = 1;
            }

            groups = Results.GetPage(CurrentPage, GroupsPerPage);

            if (groups != null && groups.Length > 0)
            {
                foreach (Group group in groups)
                {
                    Category[] categories = Category.FetchCategoriesByGroup(group.ID);

                    List<string> lCategories = new List<string>();

                    foreach (Category category in categories)
                    {
                        lCategories.Add(category.Name);
                    }

                    string[] groupCategories = lCategories.ToArray();
                    string strCategories = String.Join(", ", groupCategories);

                    string accessLevel = String.Empty;

                    switch (group.AccessLevel)
                    {
                        case Group.eAccessLevel.Public:
                            accessLevel = Lang.TransA("Public Group");
                            break;
                        case Group.eAccessLevel.Moderated:
                            accessLevel = Lang.TransA("Moderated Group");
                            break;
                        case Group.eAccessLevel.Private:
                            accessLevel = Lang.TransA("Private Group");
                            break;
                    }

                    dtGroups.Rows.Add(new object[]
                                       {
                                           group.ID,
                                           strCategories,
                                           Parsers.ProcessGroupName(group.Name),
                                           Parsers.ProcessGroupDescription(group.Description),
                                           group.Approved ? Lang.TransA("Yes") : Lang.TransA("No"),
                                           accessLevel,
                                           group.Owner,
                                           group.DateCreated
                                       });
                }
            }

            dgPendingApproval.Visible = dtGroups.Rows.Count > 0;
            dgPendingApproval.DataSource = dtGroups;
            dgPendingApproval.DataBind();
            StoreGroupIDs(dtGroups);
            DisableViewState(dgPendingApproval);
        }