예제 #1
0
        void AccountCompose_Show(object sender, EventArgs e)
        {
            SetTemplate("account_compose");

            /*List<MailFolder> folders = MailFolder.GetFolders(core, core.Session.LoggedInMember);

            foreach (MailFolder f in folders)
            {
                if (f.FolderType == FolderTypes.Inbox) continue;

                VariableCollection modulesVariableCollection = core.Template.CreateChild("account_links");
                ParentModulesVariableCollection.CreateChild("account_links", modulesVariableCollection);

                Dictionary<string, string> args = new Dictionary<string, string>();
                args.Add("folder", f.FolderName);

                switch (f.FolderType)
                {
                    case FolderTypes.Draft:
                        modulesVariableCollection.Parse("TITLE", core.Prose.GetString("DRAFTS"));
                        break;
                    case FolderTypes.Outbox:
                        modulesVariableCollection.Parse("TITLE", core.Prose.GetString("OUTBOX"));
                        break;
                    case FolderTypes.SentItems:
                        modulesVariableCollection.Parse("TITLE", core.Prose.GetString("SENT_ITEMS"));
                        break;
                    default:
                        modulesVariableCollection.Parse("TITLE", f.FolderName);
                        break;
                }
                modulesVariableCollection.Parse("SUB", Key);
                modulesVariableCollection.Parse("MODULE", ModuleKey);
                modulesVariableCollection.Parse("URI", BuildUri(args));
            }*/

            long messageId = core.Functions.FormLong("id", 0);
            bool edit = false;

            UserSelectBox toUserSelectBox = new UserSelectBox(core, "to");
            UserSelectBox ccUserSelectBox = new UserSelectBox(core, "cc");
            TextBox subjectTextBox = new TextBox("subject");
            TextBox messageTextBox = new TextBox("message");
            messageTextBox.IsFormatted = true;

            Message message = null;
            try
            {
                message = new Message(core, messageId);
                if (message.SenderId == core.Session.LoggedInMember.Id)
                {
                    edit = true;
                }
                else
                {
                    core.Functions.Generate403();
                }
            }
            catch (InvalidMessageException)
            {
            }

            if (edit)
            {
                subjectTextBox.Value = message.Subject;
                messageTextBox.Value = message.Text;

                List<MessageRecipient> recipients = message.GetRecipients();

                foreach (MessageRecipient recipient in recipients)
                {
                    switch (recipient.RecipientType)
                    {
                        case RecipientType.To:
                            toUserSelectBox.AddUserId(recipient.UserId);
                            break;
                        case RecipientType.Cc:
                            ccUserSelectBox.AddUserId(recipient.UserId);
                            break;
                    }
                }

                if (message.Draft)
                {
                    template.Parse("SAVE_DRAFT", "TRUE");
                }
                else
                {
                    template.Parse("SAVE_DRAFT", "FALSE");
                }
            }
            else
            {
                template.Parse("SAVE_DRAFT", "TRUE");
            }

            template.Parse("S_TO", toUserSelectBox);
            template.Parse("S_CC", ccUserSelectBox);

            template.Parse("S_SUBJECT", subjectTextBox);
            template.Parse("S_MESSAGE", messageTextBox);

            if (core.Http.Form["save"] != null)
            {
                AccountCompose_Save(this, new EventArgs());
            }

            if (core.Http.Form["send"] != null)
            {
                AccountCompose_Send(this, new EventArgs());
            }
        }
예제 #2
0
        void AccountSubGroupsManage_Members(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_group_subgroup_members");

            long id = core.Functions.RequestLong("id", 0);

            if (id <= 0)
            {
                return;
            }

            try
            {
                subUserGroup = new SubUserGroup(core, id);
            }
            catch (InvalidSubGroupException)
            {
                return;
            }

            if (subUserGroup.CanEditItem())
            {
                List<SubGroupMember> leaders = subUserGroup.GetLeaders();
                List<SubGroupMember> awaiting = subUserGroup.GetMembersWaitingApproval();
                List<SubGroupMember> members = subUserGroup.GetMembers(core.TopLevelPageNumber, 25);

                UserSelectBox newUserSelectBox = new UserSelectBox(core, "usernames");
                newUserSelectBox.SelectMultiple = false;
                //Form.AddFormField(newUserSelectBox);

                YesNoList makeLeaderYesNoList = new YesNoList(core, "make-leader");
                makeLeaderYesNoList.SelectedKey = "no";
                //Form.AddFormField(makeLeaderYesNoList);

                YesNoList makeDefaultYesNoList = new YesNoList(core, "make-default");
                makeDefaultYesNoList.SelectedKey = "no";
                //Form.AddFormField(makeDefaultYesNoList);

                template.Parse("SUBGROUP_DISPLAY_NAME", subUserGroup.DisplayName);
                template.Parse("S_USERNAMES", newUserSelectBox);
                template.Parse("S_MAKE_LEADER", makeLeaderYesNoList);
                template.Parse("S_MAKE_DEFAULT_GROUP", makeDefaultYesNoList);
                template.Parse("S_GROUP_ID", subUserGroup.Id.ToString());

                foreach (SubGroupMember member in leaders)
                {
                    CheckBox memberCheckBox = new CheckBox("check[" + member.Id.ToString() + "]");

                    VariableCollection memberVariableCollection = template.CreateChild("leader_list");
                    memberVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                    memberVariableCollection.Parse("JOINED_DATE", core.Tz.DateTimeToDateString(member.GetJoinedDate(core.Tz)));
                    memberVariableCollection.Parse("S_MARK", memberCheckBox);

                    if (member.IsDefaultGroup)
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("YES"));
                    }
                    else
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("NO"));
                    }
                }

                foreach (SubGroupMember member in awaiting)
                {
                    CheckBox memberCheckBox = new CheckBox("check[" + member.Id.ToString() + "]");

                    VariableCollection memberVariableCollection = template.CreateChild("awaiting_list");
                    memberVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                    memberVariableCollection.Parse("JOINED_DATE", core.Tz.DateTimeToDateString(member.GetJoinedDate(core.Tz)));
                    memberVariableCollection.Parse("S_MARK", memberCheckBox);

                    if (member.IsDefaultGroup)
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("YES"));
                    }
                    else
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("NO"));
                    }
                }

                foreach (SubGroupMember member in members)
                {
                    CheckBox memberCheckBox = new CheckBox("check[" + member.Id.ToString() + "]");

                    VariableCollection memberVariableCollection = template.CreateChild("member_list");
                    memberVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                    memberVariableCollection.Parse("JOINED_DATE", core.Tz.DateTimeToDateString(member.GetJoinedDate(core.Tz)));
                    memberVariableCollection.Parse("S_MARK", memberCheckBox);

                    if (member.IsDefaultGroup)
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("YES"));
                    }
                    else
                    {
                        memberVariableCollection.Parse("DEFAULT_GROUP", core.Prose.GetString("NO"));
                    }
                }

            }
            else
            {
                return;
            }

            Save(AccountSubGroupsManage_Members_AddNew);
        }
예제 #3
0
        void AccountLifestyle_Show(object sender, EventArgs e)
        {
            if (core.ResponseFormat != ResponseFormats.Html)
            {
                AccountLifestyle_SaveParameter(sender, e);
                return;
            }

            Save(new EventHandler(AccountLifestyle_Save));

            SetTemplate("account_lifestyle");

            SelectBox maritialStatusesSelectBox = new SelectBox("maritial-status");
            maritialStatusesSelectBox.Add(new SelectBoxItem(((byte)MaritialStatus.Undefined).ToString(), core.Prose.GetString("NO_ANSWER")));
            maritialStatusesSelectBox.Add(new SelectBoxItem(((byte)MaritialStatus.Single).ToString(), core.Prose.GetString("SINGLE")));
            maritialStatusesSelectBox.Add(new SelectBoxItem(((byte)MaritialStatus.MonogomousRelationship).ToString(), core.Prose.GetString("IN_A_RELATIONSHIP")));
            maritialStatusesSelectBox.Add(new SelectBoxItem(((byte)MaritialStatus.OpenRelationship).ToString(), core.Prose.GetString("IN_A_OPEN_RELATIONSHIP")));
            maritialStatusesSelectBox.Add(new SelectBoxItem(((byte)MaritialStatus.Engaged).ToString(), core.Prose.GetString("ENGAGED")));
            maritialStatusesSelectBox.Add(new SelectBoxItem(((byte)MaritialStatus.Married).ToString(), core.Prose.GetString("MARRIED")));
            maritialStatusesSelectBox.Add(new SelectBoxItem(((byte)MaritialStatus.Separated).ToString(), core.Prose.GetString("SEPARATED")));
            maritialStatusesSelectBox.Add(new SelectBoxItem(((byte)MaritialStatus.Divorced).ToString(), core.Prose.GetString("DIVORCED")));
            maritialStatusesSelectBox.Add(new SelectBoxItem(((byte)MaritialStatus.Widowed).ToString(), core.Prose.GetString("WIDOWED")));
            maritialStatusesSelectBox.SelectedKey = ((byte)LoggedInMember.Profile.MaritialStatusRaw).ToString();

            SelectBox religionsSelectBox = new SelectBox("religion");
            religionsSelectBox.Add(new SelectBoxItem("0", core.Prose.GetString("NO_ANSWER")));

            // TODO: Fix this
            DataTable religionsTable = db.Query("SELECT * FROM religions ORDER BY religion_title ASC");

            foreach (DataRow religionRow in religionsTable.Rows)
            {
                religionsSelectBox.Add(new SelectBoxItem(((short)religionRow["religion_id"]).ToString(), (string)religionRow["religion_title"]));
            }

            religionsSelectBox.SelectedKey = LoggedInMember.Profile.ReligionId.ToString();
            religionsSelectBox.Script.OnChange = "SaveParameter('profile', 'lifestyle', '" + religionsSelectBox.Name + "');";

            SelectBox sexualitiesSelectBox = new SelectBox("sexuality");
            sexualitiesSelectBox.Add(new SelectBoxItem(((byte)Sexuality.Undefined).ToString(), core.Prose.GetString("NO_ANSWER")));
            sexualitiesSelectBox.Add(new SelectBoxItem(((byte)Sexuality.Unsure).ToString(), core.Prose.GetString("NOT_SURE")));
            sexualitiesSelectBox.Add(new SelectBoxItem(((byte)Sexuality.Asexual).ToString(), core.Prose.GetString("ASEXUAL")));
            sexualitiesSelectBox.Add(new SelectBoxItem(((byte)Sexuality.Hetrosexual).ToString(), core.Prose.GetString("STRAIGHT")));
            sexualitiesSelectBox.Add(new SelectBoxItem(((byte)Sexuality.Homosexual).ToString(), LoggedInMember.Profile.GenderRaw == Gender.Female ? core.Prose.GetString("LESBIAN") : core.Prose.GetString("GAY")));
            sexualitiesSelectBox.Add(new SelectBoxItem(((byte)Sexuality.Bisexual).ToString(), core.Prose.GetString("BISEXUAL")));
            sexualitiesSelectBox.Add(new SelectBoxItem(((byte)Sexuality.Pansexual).ToString(), core.Prose.GetString("PANSEXUAL")));
            sexualitiesSelectBox.Add(new SelectBoxItem(((byte)Sexuality.Polysexual).ToString(), core.Prose.GetString("POLYSEXUAL")));
            sexualitiesSelectBox.SelectedKey = ((byte)LoggedInMember.Profile.SexualityRaw).ToString();
            sexualitiesSelectBox.Script.OnChange = "SaveParameter('profile', 'lifestyle', '" + sexualitiesSelectBox.Name + "');";

            CheckBoxArray interestedInCheckBoxes = new CheckBoxArray("interested-in");
            interestedInCheckBoxes.Layout = Layout.Horizontal;

            CheckBox interestedInMenCheckBox = new CheckBox("interested-in-men");
            interestedInMenCheckBox.Caption = core.Prose.GetString("MEN");
            interestedInMenCheckBox.IsChecked = LoggedInMember.Profile.InterestedInMen;
            interestedInMenCheckBox.Width = new StyleLength();
            interestedInMenCheckBox.Script.OnChange = "SaveParameter('profile', 'lifestyle', '" + interestedInMenCheckBox.Name + "');";

            CheckBox interestedInWomenCheckBox = new CheckBox("interested-in-women");
            interestedInWomenCheckBox.Caption = core.Prose.GetString("WOMEN");
            interestedInWomenCheckBox.IsChecked = LoggedInMember.Profile.InterestedInWomen;
            interestedInWomenCheckBox.Width = new StyleLength();
            interestedInWomenCheckBox.Script.OnChange = "SaveParameter('profile', 'lifestyle', '" + interestedInWomenCheckBox.Name + "');";

            interestedInCheckBoxes.Add(interestedInMenCheckBox);
            interestedInCheckBoxes.Add(interestedInWomenCheckBox);

            UserSelectBox relationUserSelectBox = new UserSelectBox(core, "relation");
            relationUserSelectBox.Width = new StyleLength();
            relationUserSelectBox.SelectMultiple = false;
            relationUserSelectBox.IsVisible = false;
            relationUserSelectBox.Script.OnChange = "SaveParameter('profile', 'lifestyle', '" + relationUserSelectBox.Name + "');";

            maritialStatusesSelectBox.Script.OnChange = "SaveParameter('profile', 'lifestyle', '" + maritialStatusesSelectBox.Name + "'); CheckRelationship('" + maritialStatusesSelectBox.Name + "', '" + relationUserSelectBox.Name + "');";

            template.Parse("S_MARITIAL_STATUS", maritialStatusesSelectBox);
            template.Parse("S_RELIGION", religionsSelectBox);
            template.Parse("S_SEXUALITY", sexualitiesSelectBox);
            template.Parse("S_INTERESTED_IN", interestedInCheckBoxes);

            switch (LoggedInMember.Profile.MaritialStatusRaw)
            {
                case MaritialStatus.MonogomousRelationship:
                case MaritialStatus.OpenRelationship:
                case MaritialStatus.Engaged:
                case MaritialStatus.Married:
                    relationUserSelectBox.IsVisible = true;
                    break;
            }

            if (LoggedInMember.Profile.MaritialWithConfirmed && LoggedInMember.Profile.MaritialWithId > 0)
            {
                relationUserSelectBox.Invitees = new List<long>(new long[] { LoggedInMember.Profile.MaritialWithId });
                core.LoadUserProfile(LoggedInMember.Profile.MaritialWithId);

                template.Parse("S_RELATIONSHIP_WITH", core.PrimitiveCache[LoggedInMember.Profile.MaritialWithId].UserName);
            }

            template.Parse("S_RELATION", relationUserSelectBox);
        }
예제 #4
0
        void AccountGroupsInvite_Show(object sender, EventArgs e)
        {
            SetTemplate("account_group_invite");

            long groupId = core.Functions.RequestLong("id", 0);

            try
            {
                UserGroup thisGroup = new UserGroup(core, groupId);

                if (!thisGroup.IsGroupMember(LoggedInMember.ItemKey))
                {
                    core.Display.ShowMessage("Error", "You must be a member of a group to invite someone to it.");
                    return;
                }

                switch (thisGroup.GroupType)
                {
                    case "OPEN":
                    case "REQUEST":
                    case "CLOSED":
                    case "PRIVATE":
                        break;
                }

                UserSelectBox inviteUserSelectBox = new UserSelectBox(core, "username");
                inviteUserSelectBox.SelectMultiple = false;

                template.Parse("S_USERNAME", inviteUserSelectBox);
                template.Parse("S_ID", groupId.ToString());
            }
            catch (InvalidGroupException)
            {
                DisplayGenericError();
            }

            Save(new EventHandler(AccountGroupsInvite_Save));
        }
예제 #5
0
        void PostContent(HookEventArgs e)
        {
            Template template = new Template(Assembly.GetExecutingAssembly(), "postevent");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

            string formSubmitUri = core.Hyperlink.AppendSid(e.Owner.AccountUriStub, true);
            template.Parse("U_ACCOUNT", formSubmitUri);
            template.Parse("S_ACCOUNT", formSubmitUri);

            int year = core.Functions.RequestInt("year", core.Tz.Now.Year);
            int month = core.Functions.RequestInt("month", core.Tz.Now.Month);
            int day = core.Functions.RequestInt("day", core.Tz.Now.Day);

            DateTimePicker startDateTimePicker = new DateTimePicker(core, "start-date");
            startDateTimePicker.ShowTime = true;
            startDateTimePicker.ShowSeconds = false;

            DateTimePicker endDateTimePicker = new DateTimePicker(core, "end-date");
            endDateTimePicker.ShowTime = true;
            endDateTimePicker.ShowSeconds = false;

            UserSelectBox inviteesUserSelectBox = new UserSelectBox(core, "invitees");

            /* */
            SelectBox timezoneSelectBox = UnixTime.BuildTimeZoneSelectBox("timezone");

            DateTime startDate = new DateTime(year, month, day, 8, 0, 0);
            DateTime endDate = new DateTime(year, month, day, 9, 0, 0);
            timezoneSelectBox.SelectedKey = core.Tz.TimeZoneCode.ToString();

            template.Parse("S_YEAR", year.ToString());
            template.Parse("S_MONTH", month.ToString());
            template.Parse("S_DAY", day.ToString());

            startDateTimePicker.Value = startDate;
            endDateTimePicker.Value = endDate;

            template.Parse("S_START_DATE", startDateTimePicker);
            template.Parse("S_END_DATE", endDateTimePicker);
            template.Parse("S_TIMEZONE", timezoneSelectBox);
            template.Parse("S_INVITEES", inviteesUserSelectBox);

            e.core.AddPostPanel(e.core.Prose.GetString("EVENT"), template);
        }
        void AccountCalendarEventNew_Show(object sender, EventArgs e)
        {
            SetTemplate("account_calendar_event_new");

            DateTimePicker startDateTimePicker = new DateTimePicker(core, "start-date");
            startDateTimePicker.ShowTime = true;
            startDateTimePicker.ShowSeconds = false;

            DateTimePicker endDateTimePicker = new DateTimePicker(core, "end-date");
            endDateTimePicker.ShowTime = true;
            endDateTimePicker.ShowSeconds = false;

            UserSelectBox inviteesUserSelectBox = new UserSelectBox(core, "invitees");

            /* */
            SelectBox timezoneSelectBox = UnixTime.BuildTimeZoneSelectBox("timezone");

            bool edit = false;

            if (core.Http.Query["mode"] == "edit")
            {
                edit = true;
            }

            int year = core.Functions.RequestInt("year", tz.Now.Year);
            int month = core.Functions.RequestInt("month", tz.Now.Month);
            int day = core.Functions.RequestInt("day", tz.Now.Day);

            string inviteeUsernameList = core.Http.Form["invitees[raw]"];
            List<long> inviteeIds = UserSelectBox.FormUsers(core, "invitees");

            if (!(string.IsNullOrEmpty(inviteeUsernameList)))
            {
                string[] inviteesUsernames = inviteeUsernameList.Split(new char[] { ' ', '\t', ';', ',' });
                List<string> uns = new List<string>(inviteesUsernames.Length);
                foreach (string inviteeUsername in inviteesUsernames)
                {
                    if (!string.IsNullOrEmpty(inviteeUsername))
                    {
                        try
                        {
                            uns.Add(inviteeUsername);
                        }
                        catch (InvalidUserException)
                        {
                        }
                    }
                }

                inviteeIds.AddRange(core.LoadUserProfiles(uns).Values);
            }

            DateTime startDate = new DateTime(year, month, day, 8, 0, 0);
            DateTime endDate = new DateTime(year, month, day, 9, 0, 0);
            timezoneSelectBox.SelectedKey = core.Tz.TimeZoneCode.ToString();

            string subject = string.Empty;
            string location = string.Empty;
            string description = string.Empty;

            if (edit)
            {
                int id = core.Functions.RequestInt("id", -1);

                if (id < 1)
                {
                    core.Display.ShowMessage("Invalid", "If you have stumbled onto this page by mistake, click back in your browser.");
                }

                try
                {
                    Event calendarEvent = new Event(core, id);
                    inviteeIds.AddRange(calendarEvent.GetInviteeIds());

                    template.Parse("EDIT", "TRUE");
                    template.Parse("ID", calendarEvent.EventId.ToString());

                    startDate = calendarEvent.GetStartTime(core.Tz);
                    endDate = calendarEvent.GetEndTime(core.Tz);
                    inviteesUserSelectBox.Invitees = calendarEvent.GetInviteeIds();

                    subject = calendarEvent.Subject;
                    location = calendarEvent.Location;
                    description = calendarEvent.Description;
                }
                catch (InvalidEventException)
                {
                    core.Display.ShowMessage("Invalid", "If you have stumbled onto this page by mistake, click back in your browser.");
                }
            }

            template.Parse("S_YEAR", year.ToString());
            template.Parse("S_MONTH", month.ToString());
            template.Parse("S_DAY", day.ToString());

            startDateTimePicker.Value = startDate;
            endDateTimePicker.Value = endDate;

            List<string> permissions = new List<string>();
            permissions.Add("Can Read");

            //core.Display.ParsePermissionsBox(template, "S_EVENT_PERMS", eventAccess, permissions);

            template.Parse("S_SUBJECT", subject);
            template.Parse("S_LOCATION", location);
            template.Parse("S_DESCRIPTION", description);

            StringBuilder outputInvitees = null;
            StringBuilder outputInviteesIds = null;

            core.LoadUserProfiles(inviteeIds);

            foreach (long inviteeId in inviteeIds)
            {
                if (outputInvitees == null)
                {
                    outputInvitees = new StringBuilder();
                    outputInviteesIds = new StringBuilder();
                }
                else
                {
                    outputInvitees.Append("; ");
                    outputInviteesIds.Append(",");
                }

                outputInvitees.Append(core.PrimitiveCache[inviteeId].DisplayName);
                outputInviteesIds.Append(inviteeId.ToString());
            }

            if (outputInviteesIds != null)
            {
                template.Parse("INVITEES_ID_LIST", outputInviteesIds.ToString());
            }

            template.Parse("S_START_DATE", startDateTimePicker);
            template.Parse("S_END_DATE", endDateTimePicker);
            template.Parse("S_TIMEZONE", timezoneSelectBox);
            template.Parse("S_INVITEES", inviteesUserSelectBox);

            Save(new EventHandler(AccountCalendarEventNew_Save));
        }