public void linkLeave_Click(object sender, EventArgs e)
    {
        TransitAccountGroupAccount t_account = GetAccountGroupAccount();

        SessionManager.GroupService.DeleteAccountGroupAccount(SessionManager.Ticket, t_account.Id);
        Redirect(string.Format("AccountGroupView.aspx?id={0}", AccountGroupId));
    }
    public void gridManage_ItemCommand(object sender, DataListCommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "Delete":
        {
            int id = int.Parse(e.CommandArgument.ToString());
            SessionManager.Delete <TransitAccountGroupAccount>(id, SessionManager.GroupService.DeleteAccountGroupAccount);
            ReportInfo("Member deleted.");
            GetData(sender, e);
            break;
        }

        case "Promote":
        {
            TransitAccountGroupAccount t_account = SessionManager.GroupService.GetAccountGroupAccountById(
                SessionManager.Ticket, int.Parse(e.CommandArgument.ToString()));
            t_account.IsAdministrator = true;
            SessionManager.CreateOrUpdate <TransitAccountGroupAccount>(
                t_account, SessionManager.GroupService.CreateOrUpdateAccountGroupAccount);
            ReportInfo("Member promoted.");
            gridManage_OnGetDataSource(sender, e);
            gridManage.DataBind();
            break;
        }

        case "Demote":
        {
            TransitAccountGroupAccount t_account = SessionManager.GroupService.GetAccountGroupAccountById(
                SessionManager.Ticket, int.Parse(e.CommandArgument.ToString()));
            t_account.IsAdministrator = false;
            SessionManager.CreateOrUpdate <TransitAccountGroupAccount>(
                t_account, SessionManager.GroupService.CreateOrUpdateAccountGroupAccount);
            ReportInfo("Member demoted.");
            gridManage_OnGetDataSource(sender, e);
            gridManage.DataBind();
            break;
        }
        }
    }
    public void linkRequest_Click(object sender, EventArgs e)
    {
        string requesturi = string.Format("AccountGroupAccountRequestEdit.aspx?gid={0}", AccountGroupId);

        if (!SessionManager.IsLoggedIn)
        {
            RedirectToLogin(requesturi);
            return;
        }

        if (AccountGroup.IsPrivate && !SessionManager.IsAdministrator)
        {
            Redirect(requesturi);
        }
        else
        {
            TransitAccountGroupAccount t_instance = new TransitAccountGroupAccount();
            t_instance.AccountId       = SessionManager.AccountId;
            t_instance.AccountGroupId  = AccountGroupId;
            t_instance.IsAdministrator = false;
            SessionManager.GroupService.CreateOrUpdateAccountGroupAccount(SessionManager.Ticket, t_instance);
            Redirect(string.Format("AccountGroupView.aspx?id={0}", AccountGroupId));
        }
    }
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (AccountGroup == null)
            {
                ReportWarning("Group does not exist.");
                pnlAccountGroup.Visible = false;
                return;
            }

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Groups", Request, "AccountGroupsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(AccountGroup.Name, Request.Url));
            StackSiteMap(sitemapdata);

            this.Title = Renderer.Render(AccountGroup.Name);

            TransitAccountGroupAccount t_account = GetAccountGroupAccount();

            bool fGroupAdmin         = ((t_account != null && t_account.IsAdministrator) || SessionManager.IsAdministrator);
            bool fGroupMember        = (t_account != null);
            bool fGroupMemberOrAdmin = (fGroupMember || SessionManager.IsAdministrator);

            // links
            linkRequests.NavigateUrl     = string.Format("AccountGroupAccountRequestsManage.aspx?id={0}", AccountGroupId);
            linkRequests.Visible         = AccountGroup.IsPrivate && fGroupAdmin;
            linkPictures.NavigateUrl     = string.Format("AccountGroupPicturesManage.aspx?id={0}", AccountGroupId);
            linkPictures.Visible         = !AccountGroup.IsPrivate || fGroupMemberOrAdmin;
            linkMembers.NavigateUrl      = string.Format("AccountGroupAccountsView.aspx?id={0}", AccountGroupId);
            linkMembers.Visible          = !AccountGroup.IsPrivate || fGroupMemberOrAdmin;
            linkRequest.Visible          = !fGroupMember;
            linkLeave.Visible            = fGroupMember;
            discussionsView.Visible      = !AccountGroup.IsPrivate || fGroupMemberOrAdmin;
            linkInviteFriend.NavigateUrl = string.Format("AccountGroupAccountInvitationEdit.aspx?gid={0}", AccountGroupId);
            linkInviteFriend.Visible     = fGroupMemberOrAdmin;
            linkRelRss.Visible           = !AccountGroup.IsPrivate || fGroupMemberOrAdmin;

            linkEditGroup.NavigateUrl = string.Format("AccountGroupEdit.aspx?id={0}&ReturnUrl={1}", AccountGroupId,
                                                      Renderer.UrlEncode(string.Format("AccountGroupView.aspx?id={0}", RequestId)));

            panelGroupAdmin.Visible = fGroupAdmin;

            // text
            titleGroup.Text = Renderer.Render(AccountGroup.Name);

            // action
            string action = Request["action"];
            if (!string.IsNullOrEmpty(action))
            {
                switch (action)
                {
                case "join":
                    linkRequest_Click(sender, e);
                    break;

                case "leave":
                    linkLeave_Click(sender, e);
                    break;
                }
            }

            // feature
            if (SessionManager.IsAdministrator)
            {
                linkFeature.Text = (LatestAccountGroupFeature != null)
                    ? string.Format("Feature &#187; Last on {0}", Adjust(LatestAccountGroupFeature.Created).ToString("d"))
                    : "Feature &#187; Never Featured";
            }

            if (!SessionManager.IsLoggedIn)
            {
                noticeInfo.Info = "Log-in to participate in this group and post.";
            }
            else if (!fGroupMember)
            {
                noticeInfo.Info = "Join this group to participate and posts.";
            }

            // private / public
            if (AccountGroup.IsPrivate && !fGroupMemberOrAdmin)
            {
                if (!SessionManager.IsLoggedIn)
                {
                    RedirectToLogin();
                }
                else
                {
                    blogView.Visible = false;
                    ReportWarning("This is a private group. You must be a member to see it.");
                }

                return;
            }

            picturesView.AccountGroupId = AccountGroupId;
            accountsView.AccountGroupId = AccountGroupId;

            placesView.AccountGroupId = AccountGroupId;
            discussionsView.ObjectId  = RequestId;
            discussionsView.Type      = "AccountGroup";

            linkRelRss.NavigateUrl = string.Format("AccountGroupRss.aspx?id={0}", AccountGroupId);

            // blog
            blogView.Visible = (AccountGroup.AccountBlogId > 0);
            blogView.BlogId  = AccountGroup.AccountBlogId;
            blogView.DataBind();
        }
    }
Exemple #5
0
 public int CreateOrUpdateAccountGroupAccount(string ticket, TransitAccountGroupAccount t_instance)
 {
     return WebServiceImpl<TransitAccountGroupAccount, ManagedAccountGroupAccount, AccountGroupAccount>.CreateOrUpdate(
         ticket, t_instance);
 }
    public void linkRequest_Click(object sender, EventArgs e)
    {
        string requesturi = string.Format("AccountGroupAccountRequestEdit.aspx?gid={0}", AccountGroupId);

        if (!SessionManager.IsLoggedIn)
        {
            RedirectToLogin(requesturi);
            return;
        }

        if (AccountGroup.IsPrivate && ! SessionManager.IsAdministrator)
        {
            Redirect(requesturi);
        }
        else
        {
            TransitAccountGroupAccount t_instance = new TransitAccountGroupAccount();
            t_instance.AccountId = SessionManager.AccountId;
            t_instance.AccountGroupId = AccountGroupId;
            t_instance.IsAdministrator = false;
            SessionManager.GroupService.CreateOrUpdateAccountGroupAccount(SessionManager.Ticket, t_instance);
            Redirect(string.Format("AccountGroupView.aspx?id={0}", AccountGroupId));
        }
    }
Exemple #7
0
 public int CreateOrUpdateAccountGroupAccount(string ticket, TransitAccountGroupAccount t_instance)
 {
     return(WebServiceImpl <TransitAccountGroupAccount, ManagedAccountGroupAccount, AccountGroupAccount> .CreateOrUpdate(
                ticket, t_instance));
 }