/// <summary>
        /// Usess the request or session SA value along with the session MasterAcctPID value to
        /// determine if the logged in patron can impersonate the patron with the SA patron id.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public FamilyRelationship ValidImpersonation(HttpRequest request, HttpSessionState session)
        {
            string sa;

            if (string.IsNullOrEmpty(request[SessionKey.SA]) &&
                (session[SessionKey.SA] == null || string.IsNullOrEmpty(session[SessionKey.SA].ToString())))
            {
                return(null);
            }
            if (!string.IsNullOrEmpty(request[SessionKey.SA]))
            {
                sa = request[SessionKey.SA];
                session[SessionKey.SA] = sa;
            }
            else
            {
                sa = session[SessionKey.SA].ToString();
            }

            var parent = Patron.FetchObject((int)session[SessionKey.MasterAcctPID]);

            if (!parent.IsMasterAccount ||
                !Patron.CanManageSubAccount(parent.PID, int.Parse(sa)))
            {
                return(null);
            }

            return(new FamilyRelationship {
                PatronId = int.Parse(sa),
                ParentPatronId = parent.PID
            });
        }
Exemple #2
0
        protected void rptr_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            Session["SA"] = "0";
            if (e.CommandName == "pwd")
            {
                Session["SA"] = e.CommandArgument.ToString();
                Response.Redirect("~/Account/ChangeFamMemberPwd.aspx");
            }
            if (e.CommandName == "log")
            {
                Session["SA"] = e.CommandArgument.ToString();
                Response.Redirect("~/Account/EnterFamMemberLog.aspx");
            }
            if (e.CommandName == "login")
            {
                var newPID = int.Parse(e.CommandArgument.ToString());

                if ((int)Session["MasterAcctPID"] != newPID &&
                    !Patron.CanManageSubAccount((int)Session["MasterAcctPID"], newPID))
                {
                    // kick them out
                    Response.Redirect("~");
                }

                var newPatron = Patron.FetchObject(newPID);
                new SessionTools(Session).EstablishPatron(newPatron);
                //Session["Patron"] = bp;
                //Session["ProgramID"] = bp.ProgID;
                //Session["TenantID"] = bp.TenID;

                Response.Redirect("~");
            }
        }
Exemple #3
0
        protected void rptr_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            Session["SA"] = "0";
            if (e.CommandName == "pwd")
            {
                Session["SA"] = e.CommandArgument.ToString();
                Response.Redirect("~/Account/ChangeFamMemberPwd.aspx");
            }
            if (e.CommandName == "log")
            {
                Session["SA"] = e.CommandArgument.ToString();
                Response.Redirect("~/Account/EnterFamMemberLog.aspx");
            }
            if (e.CommandName == "login")
            {
                var newPID = int.Parse(e.CommandArgument.ToString());

                if ((int)Session["MasterAcctPID"] != newPID &&
                    !Patron.CanManageSubAccount((int)Session["MasterAcctPID"], newPID))
                {
                    // kick them out
                    Response.Redirect("~");
                }

                var newPatron = Patron.FetchObject(newPID);
                new SessionTools(Session).EstablishPatron(newPatron);


                var pgm = DAL.Programs.FetchObject(newPatron.ProgID);

                /* recalulate goal cache to accomdate changes in program length and point multipliers */
                ProgramGamePointConversion pgc = null;
                foreach (ActivityType activityTypeValue in Enum.GetValues(typeof(ActivityType)))
                {
                    int activityTypeId = (int)activityTypeValue;
                    var temp           = ProgramGamePointConversion.FetchObjectByActivityId(pgm.PID,
                                                                                            +activityTypeId);
                    if (temp != null && temp.PointCount > 0)
                    {
                        pgc = temp;
                    }
                }
                if (pgc != null)
                {
                    newPatron.RecalculateGoalCache(pgm, pgc);
                    newPatron.Update();
                }

                TestingBL.CheckPatronNeedsPreTest();
                TestingBL.CheckPatronNeedsPreTest();

                Response.Redirect("~");
            }
        }
Exemple #4
0
        /// <summary>
        /// Usess the request or session SA value along with the session MasterAcctPID value to
        /// determine if the logged in patron can impersonate the patron with the SA patron id.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public FamilyRelationship ValidImpersonation(HttpRequest request, HttpSessionState session)
        {
            string sa;

            if (string.IsNullOrEmpty(request[SessionKey.SA]) &&
                (session[SessionKey.SA] == null || string.IsNullOrEmpty(session[SessionKey.SA].ToString())))
            {
                return(null);
            }
            if (!string.IsNullOrEmpty(request[SessionKey.SA]))
            {
                sa = request[SessionKey.SA];
                session[SessionKey.SA] = sa;
            }
            else
            {
                sa = session[SessionKey.SA].ToString();
            }

            var parent = Patron.FetchObject((int)session[SessionKey.MasterAcctPID]);

            if (parent == null)
            {
                this.Log().Error("Attempting to verify family relationship failed: session MasterAcctPID = {0}, parent object is null",
                                 session[SessionKey.MasterAcctPID]);
                return(null);
            }
            else
            {
                if (!parent.IsMasterAccount ||
                    !Patron.CanManageSubAccount(parent.PID, int.Parse(sa)))
                {
                    return(null);
                }
            }

            return(new FamilyRelationship
            {
                PatronId = int.Parse(sa),
                ParentPatronId = parent.PID
            });
        }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(Request["SA"]) && (Session["SA"] == null || Session["SA"].ToString() == ""))
                {
                    Response.Redirect("~/FamilyAccountList.aspx");
                }
                if (!string.IsNullOrEmpty(Request["SA"]))
                {
                    SA.Text       = Request["SA"];
                    Session["SA"] = SA.Text;
                }
                else
                {
                    SA.Text = Session["SA"].ToString();
                }

                // now validate user can change password for SA Sub Account

                //var patron = (Patron)Session["Patron"];
                //if (!patron.IsMasterAccount)
                if (Session[SessionKey.IsMasterAccount] == null || !(bool)Session[SessionKey.IsMasterAccount])
                {
                    // kick them out
                    Response.Redirect("~/Logout.aspx");
                }

                if (!Patron.CanManageSubAccount((int)Session["MasterAcctPID"], int.Parse(SA.Text)))
                {
                    // kick them out
                    Response.Redirect("~/Logout.aspx");
                }
                var sa = Patron.FetchObject(int.Parse(SA.Text));
                rptr.DataSource = Patron.GetPatronForEdit(sa.PID);
                rptr.DataBind();

                ((BaseSRPPage)Page).TranslateStrings(rptr);
            }
        }
Exemple #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(Request["SA"]) && (Session["SA"] == null || Session["SA"].ToString() == ""))
                {
                    Response.Redirect("~/FamilyAccountList.aspx");
                }
                if (!string.IsNullOrEmpty(Request["SA"]))
                {
                    SA.Text       = Request["SA"];
                    Session["SA"] = SA.Text;
                }
                else
                {
                    SA.Text = Session["SA"].ToString();
                }

                // now validate user can change password for SA Sub Account

                var patron = (Patron)Session["Patron"];
                if (!patron.IsMasterAccount)
                {
                    // kick them out
                    Response.Redirect("~/Logout.aspx");
                }

                if (!Patron.CanManageSubAccount(patron.PID, int.Parse(SA.Text)))
                {
                    // kick them out
                    Response.Redirect("~/Logout.aspx");
                }
                var sa = Patron.FetchObject(int.Parse(SA.Text));
                lblAccount.Text = (sa.FirstName + " " + sa.LastName).Trim();
                if (lblAccount.Text.Length == 0)
                {
                    lblAccount.Text = sa.Username;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(Request["SA"]) && (Session["SA"] == null || Session["SA"].ToString() == ""))
                {
                    Response.Redirect("~/Account/FamilyAccountList.aspx");
                }
                if (!string.IsNullOrEmpty(Request["SA"]))
                {
                    SA.Text       = Request["SA"];
                    Session["SA"] = SA.Text;
                }
                else
                {
                    SA.Text = Session["SA"].ToString();
                }

                // now validate user can change password for SA Sub Account

                var patron = (Patron)Session["Patron"];
                //if (!patron.IsMasterAccount)
                if (Session[SessionKey.IsMasterAccount] == null || !(bool)Session[SessionKey.IsMasterAccount])
                {
                    // kick them out
                    Response.Redirect("~");
                }

                if (!Patron.CanManageSubAccount((int)Session["MasterAcctPID"], int.Parse(SA.Text)))
                {
                    // kick them out
                    Response.Redirect("~");
                }
                var sa = Patron.FetchObject(int.Parse(SA.Text));

                lblAccount.Text = DisplayHelper.FormatName(sa.FirstName, sa.LastName, sa.Username);
            }
        }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(Request["SA"]) && (Session["SA"] == null || Session["SA"].ToString() == ""))
                {
                    Response.Redirect("~/FamilyAccountList.aspx");
                }
                if (!string.IsNullOrEmpty(Request["SA"]))
                {
                    lblPID.Text   = Request["SA"];
                    Session["SA"] = lblPID.Text;
                }
                else
                {
                    lblPID.Text = Session["SA"].ToString();
                }

                var parent = (Patron)Session["Patron"];
                lblParentPID.Text = parent.PID.ToString();

                // now validate user can change manage log for SA Sub Account
                if (!parent.IsMasterAccount)
                {
                    // kick them out
                    Response.Redirect("~/Logout.aspx");
                }

                if (!Patron.CanManageSubAccount(parent.PID, int.Parse(lblPID.Text)))
                {
                    // kick them out
                    Response.Redirect("~/Logout.aspx");
                }


                var patron = Patron.FetchObject(int.Parse(lblPID.Text));
                var prog   = Programs.FetchObject(patron.ProgID);
                if (prog == null)
                {
                    var progID = Programs.GetDefaultProgramForAgeAndGrade(patron.Age, patron.SchoolGrade.SafeToInt());
                    prog          = Programs.FetchObject(progID);
                    patron.ProgID = progID;
                    patron.Update();
                }

                lblPGID.Text      = prog.PID.ToString();
                pnlReview.Visible = prog.PatronReviewFlag;

                lblAccount.Text = (patron.FirstName + " " + patron.LastName).Trim();
                if (lblAccount.Text.Length == 0)
                {
                    lblAccount.Text = patron.Username;
                }


                // Load the Acticity Types to log
                foreach (ActivityType val in Enum.GetValues(typeof(ActivityType)))
                {
                    var pgc = ProgramGamePointConversion.FetchObjectByActivityId(prog.PID, (int)val);
                    if (pgc != null && pgc.PointCount > 0)
                    {
                        rbActivityType.Items.Add(new ListItem(val.ToString(), ((int)val).ToString()));
                    }
                }
                rbActivityType.SelectedIndex = 0;
            }
        }