예제 #1
0
        /// <summary>Evento de click no butão</summary>
        protected void onUpdateClick(object src, EventArgs args)
        {
            Console.WriteLine("Update click");
            if (!Page.IsValid)
            {
                Trace.Write("ProfileControl", "Fields not valid");
                Console.WriteLine("Profile fields not valid");
                return;
            }
            Console.WriteLine("Profile fields valid");
            Trace.Write("ProfileControl", "Login fields valid");

            userUpdated.Visible = true;
            User user = (User)Page.User;

            user.Nick      = nick.Text;
            user.Avatar    = avatar.Text;
            user.Website   = website.Text;
            user.Lang      = lang.SelectedValue;
            user.Skin      = int.Parse(skin.SelectedValue);
            user.ImagesDir = imagesDir.Text;

            user.Msn    = msn.Text;
            user.Icq    = icq.Text;
            user.Jabber = jabber.Text;
            user.Aim    = aim.Text;
            user.Yahoo  = yahoo.Text;

            user.Signature = signature.Text;

            if (vacation.Enabled)
            {
                Ruler ruler = Universe.instance.getRuler(user.RulerId);
                if (vacation.Checked)
                {
                    ruler.StartVacations();
                }
                else
                {
                    int forcedTime = 300;
#if DEBUG
                    forcedTime = 0;
#endif
                    if (ruler.InVacation && ruler.VacationTurns < forcedTime && !user.IsInRole("admin") && !user.IsInRole("betaTester"))
                    {
                        Information.AddInformation(string.Format(info.getContent("profile_vacation_error"), ruler.VacationTurns, forcedTime));
                        vacation.Checked = true;
                        return;
                    }
                    else
                    {
                        ruler.EndVacations();
                    }
                }
            }

            if (user.RulerId != -1)
            {
                Ruler ruler = Universe.instance.getRuler(user.RulerId);
                ruler.Name = user.Nick;
            }

            System.Web.HttpContext.Current.Cache.Remove(OrionGlobals.ForumSkinName);

            UserUtility.bd.saveUser(user, password.Text);
            Response.Redirect(OrionGlobals.calculatePath("default.aspx"));
        }