<%@ Register TagPrefix="uc1" TagName="Trailer" Src="Trailer.ascx" %>
<%@ Import Namespace="edu.jhu.Cas.Util" %>
<%@ Import Namespace="System.IO" %>

<%@ Page Language="c#" CodeBehind="GroupsContent.aspx.cs" AutoEventWireup="false"
    Inherits="edu.jhu.Cas.Web.GroupsContent" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
    <meta http-equiv="Pragma" content="no-cache" />
    <title>Groups Info</title>
    <link href="cjobs.css" rel="stylesheet">
</head>
<body>
    <form runat="server" target="_top" id="fizorm">
    <%if (ThisGroup == null) {%>
    <h2>
        <%=user%>
        's Groups</h2>
    <p class="message">
        <%=lmessage%>
    </p>
    <p>
        <% if (inviteDataSet.Tables[0].Rows.Count > 0) {%>
        <div class="Ready" style="text-align:left; padding-top:5;padding-bottom:5;margin-bottom:5">You've got pending group invitations!</div>
        <asp:DataGrid ID="inviteGrid" runat="server" DataSource="<% #inviteDataSet %>" BorderStyle="None"
            CellPadding="4" AutoGenerateColumns="False" OnItemCommand="InviteCommand" EnableViewState="false"
            AllowSorting="True">
            <HeaderStyle Font-Bold="True"></HeaderStyle>
            <Columns>
                <asp:ButtonColumn Text="Accept" CommandName="Accept"/>
                <asp:ButtonColumn Text="Decline" CommandName="Decline" />
                <asp:BoundColumn DataField="Name" HeaderText="Name" />                
                <asp:BoundColumn DataField="description" HeaderText="Description"/>
                <asp:BoundColumn DataField="description" HeaderText="Description"/>
                <asp:BoundColumn DataField="gid" HeaderText="GroupID" Visible="False" />
            </Columns>
        </asp:DataGrid>
        <%} %>
    </p>
    <p>
        <asp:Button Text="Create Group" OnClick="Create" ID="createButton" runat="server" />
        <!--<a target="help" href="faq.aspx#q21">?</a>-->
    </p>
    <p>
        Groups you subscribe to are represented as links on the left. From the individual
        group pages you can:
    </p>
    <p>
        <li>View various information about a particular group
            <li>Update group information (admin only)
                <li>Unsubscribe from a group
                    <li>Manage group members (admin only)
                        <li>Destroy a group (admin only)
                            <p>
                            </p>
                            <%} else { %>
                            <h2>
                                <%=ThisGroup.Name%>
                            </h2>
                            <%if (wsid == ThisGroup.Owner) {%>
                            <p>
                                You are the <font>admin</font> for this group</p>
                            <p>
                                <asp:Button Text="Manage Users" ID="manageButton" OnClick="Manage" runat="server" />
                                <!--<a target="help" href="faq.aspx#q22">?</a>-->
                            </p>
                            <p>
                                <b>Description:</b><br>
                                <asp:TextBox runat="server" TextMode="MultiLine" Rows="5" Columns="50" ID="DescriptionBox" /><br>
                                <asp:Button CausesValidation="True" runat="server" Text="Set" OnClick="SetGroupDescription"
                                    ID="groupDescriptionSetButton" />
                                <!--<a target="help" href="faq.aspx#q23">?</a>-->
                            </p>
                            <%} else {%>
                            <p>
                                <b>Admin:</b>&nbsp; <font>
                                    <%=ThisGroup.AdminID%>
                                </font>
                            </p>
                            <p>
                                <b>Description:</b><br>
                                <i>
                                    <%=ThisGroup.Description%>
                                </i>
                            </p>
                            <%}%>
                            <b>Tables:</b>
                            <%if(GTables.Length > 0){ %>
                            <table>
                            <%foreach (edu.jhu.Cas.Util.Table tab in GTables) { %>
                            <tr><td class="group"><%=tab.GetSQLName()%></td></tr>
                            <%} %>
                            <%} else{%>
                            <i>None</i>
                            <%} %>
                            </table>
                            <%if (ThisGroup.GID != edu.jhu.Cas.Util.ID.PUBLIC_GID) { %>
                            <p>
                                <b>Members:</b><br>
                                <asp:DataGrid ID="membersGrid" runat="server" DataSource="<% #membersDataSet %>"
                                    BorderStyle="None" BorderWidth="1px" CellPadding="4" AutoGenerateColumns="false"
                                    EnableViewState="false" AllowSorting="True">
                                    <HeaderStyle Font-Bold="True"></HeaderStyle>
                                    <Columns>
                                        <asp:BoundColumn DataField="userid" HeaderText="UserID" />
                                        <asp:BoundColumn DataField="Name" HeaderText="Name" />
                                        <asp:BoundColumn DataField="email" HeaderText="EMail" />
                                    </Columns>
                                </asp:DataGrid>
                            </p>
                            <%} %>
                            <%if (wsid == ThisGroup.Owner) {%>
                            <!--bottom items -->
                            <p>
                                <asp:Button Text="Destroy Group" ID="destroyButton" OnClick="Destroy" runat="server" />
                                <!--<a target="help" href="faq.aspx#q25">?</a>-->
                            </p>
                            <%} else { %>
                            <%if (ThisGroup.GID != edu.jhu.Cas.Util.ID.PUBLIC_GID) { %>
                            <p>
                                <asp:Button Text="Unsubscribe" OnClick="Remove" ID="Button2" runat="server" />
                                <!--<a target="help" href="faq.aspx#q24">?</a>-->
                            </p>
                            <%} %>
                            <%}%>
                            <%}%>
    </form>
    <uc1:Trailer ID="Trailer1" runat="server" cvsTag="$Name$" cvsRev="$Revision: 132244 $">
    </uc1:Trailer>
    </LI>
</body>
</html>
