void AccountContactManage_AddEmail(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_email_edit");

            /**/
            TextBox emailTextBox = new TextBox("email-address");

            /**/
            SelectBox emailTypeSelectBox = new SelectBox("phone-type");
            emailTypeSelectBox.Add(new SelectBoxItem(((byte)EmailAddressTypes.Personal).ToString(), "Personal"));
            emailTypeSelectBox.Add(new SelectBoxItem(((byte)EmailAddressTypes.Business).ToString(), "Business"));
            emailTypeSelectBox.Add(new SelectBoxItem(((byte)EmailAddressTypes.Student).ToString(), "Student"));
            emailTypeSelectBox.Add(new SelectBoxItem(((byte)EmailAddressTypes.Other).ToString(), "Other"));

            switch (e.Mode)
            {
                case "add-email":
                    break;
                case "edit-email":
                    long emailId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0));
                    UserEmail email = null;

                    if (emailId > 0)
                    {
                        try
                        {
                            email = new UserEmail(core, emailId);

                            emailTextBox.IsDisabled = true;
                            emailTextBox.Value = email.Email;

                            if (emailTypeSelectBox.ContainsKey(((byte)email.EmailType).ToString()))
                            {
                                emailTypeSelectBox.SelectedKey = ((byte)email.EmailType).ToString();
                            }

                            template.Parse("S_ID", email.Id.ToString());
                        }
                        catch (InvalidUserEmailException)
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }

                    template.Parse("EDIT", "TRUE");
                    break;
            }

            template.Parse("S_EMAIL", emailTextBox);
            template.Parse("S_EMAIL_TYPE", emailTypeSelectBox);
        }
Beispiel #2
0
        public override string ToString(Forms.DisplayMedium medium)
        {
            // This will be a complicated mishmash of javascript

            HiddenField modeHiddenField = new HiddenField(name + "--mode");
            modeHiddenField.Class = "date-mode";
            modeHiddenField.Value = "forms";

            TextBox dateExpressionTextBox = new TextBox(name + "--expression");
            //dateExpressionTextBox.IsVisible = false;
            dateExpressionTextBox.Script.OnChange = "ParseDatePicker('" + name + "--expression" + "', " + (int)medium + ")";
            dateExpressionTextBox.Width.Length = Width.Length * 0.4F;
            dateExpressionTextBox.Width.Unit = Width.Unit;
            if (medium == DisplayMedium.Mobile)
            {
                dateExpressionTextBox.Type = InputType.Date;
            }

            TextBox timeExpressionTextBox = new TextBox(name + "--time");
            //timeExpressionTextBox.IsVisible = false;
            timeExpressionTextBox.Script.OnChange = "ParseTimePicker('" + name + "--time" + "')";
            timeExpressionTextBox.Width.Length = Width.Length * 0.4F;
            timeExpressionTextBox.Width.Unit = Width.Unit;
            if (medium == DisplayMedium.Mobile)
            {
                timeExpressionTextBox.Type = InputType.Time;
            }

            SelectBox dateYearsSelectBox = new SelectBox(name + "--date-year");
            SelectBox dateMonthsSelectBox = new SelectBox(name + "--date-month");
            SelectBox dateDaysSelectBox = new SelectBox(name + "--date-day");

            SelectBox dateHoursSelectBox = new SelectBox(name + "--date-hour");
            SelectBox dateMinutesSelectBox = new SelectBox(name + "--date-minute");
            SelectBox dateSecondsSelectBox = new SelectBox(name + "--date-second");

            for (int i = DateTime.Now.AddYears(-30).Year; i < DateTime.Now.AddYears(5).Year; i++)
            {
                dateYearsSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            for (int i = 1; i < 13; i++)
            {
                dateMonthsSelectBox.Add(new SelectBoxItem(i.ToString(), core.Functions.IntToMonth(i)));
                dateMonthsSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            for (int i = 1; i < 32; i++)
            {
                dateDaysSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            for (int i = 0; i < 24; i++)
            {
                dateHoursSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            for (int i = 0; i < 60; i++)
            {
                dateMinutesSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            for (int i = 0; i < 60; i++)
            {
                dateSecondsSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            dateYearsSelectBox.SelectedKey = value.Year.ToString();
            dateMonthsSelectBox.SelectedKey = value.Month.ToString();
            dateDaysSelectBox.SelectedKey = value.Day.ToString();

            if (medium == DisplayMedium.Mobile)
            {
                dateExpressionTextBox.Value = value.ToString("yyyy-MM-dd");
            }
            else
            {
                dateExpressionTextBox.Value = value.ToString("dd/MM/yyyy");
            }
            timeExpressionTextBox.Value = value.ToString("HH:mm:ss");

            /* Build display */
            StringBuilder sb = new StringBuilder();

            if (medium == DisplayMedium.Mobile)
            {
                sb.AppendLine("<div class=\"date-field\">");
                sb.AppendLine(modeHiddenField.ToString());

                sb.AppendLine("<p id=\"" + name + "[date-field]\" class=\"date-exp\" style=\"display: none;\">");
                sb.Append(core.Prose.GetString("DATE") + ": ");
                sb.Append(dateExpressionTextBox.ToString());
                if (ShowTime)
                {
                    sb.Append(" " + core.Prose.GetString("TIME") + ": ");
                    sb.Append(timeExpressionTextBox.ToString());
                }
                sb.Append("</p>");

                sb.AppendLine("</div>");
            }
            else
            {
                sb.AppendLine("<div class=\"date-field\">");
                sb.AppendLine(modeHiddenField.ToString());

                sb.AppendLine("<p id=\"" + name + "[date-drop]\" class=\"date-drop\">");
                sb.Append(core.Prose.GetString("YEAR") + ": ");
                sb.AppendLine(dateYearsSelectBox.ToString());
                sb.AppendLine(" " + core.Prose.GetString("MONTH") + ": ");
                sb.AppendLine(dateMonthsSelectBox.ToString());
                sb.AppendLine(" " + core.Prose.GetString("DAY") + ": ");
                sb.AppendLine(dateDaysSelectBox.ToString());

                if (showTime)
                {
                    sb.AppendLine(" " + core.Prose.GetString("HOUR") + ": ");
                    sb.AppendLine(dateHoursSelectBox.ToString());
                    sb.AppendLine(" " + core.Prose.GetString("MINUTE") + ": ");
                    sb.AppendLine(dateMinutesSelectBox.ToString());
                    if (showSeconds)
                    {
                        sb.AppendLine(" " + core.Prose.GetString("SECOND") + ": ");
                        sb.AppendLine(dateSecondsSelectBox.ToString());
                    }
                }
                sb.Append("</p>");

                sb.AppendLine("<p id=\"" + name + "[date-field]\" class=\"date-exp\" style=\"display: none;\">");
                sb.Append(core.Prose.GetString("DATE") + ": ");
                sb.Append(dateExpressionTextBox.ToString());
                if (ShowTime)
                {
                    sb.Append(" " + core.Prose.GetString("TIME") + ": ");
                    sb.Append(timeExpressionTextBox.ToString());
                }
                sb.Append("</p>");

                sb.AppendLine("</div>");

                sb.AppendLine("<script type=\"text/javascript\">//<![CDATA[");
                sb.AppendLine("dtp.push(Array(\"" + name + "[date-drop]\",\"" + name + "[date-field]\"));");
                sb.AppendLine("EnableDateTimePickers();");
                sb.AppendLine("//]]></script>");
            }

            return sb.ToString();
        }
        void AccountGroupsEdit_Show(object sender, EventArgs e)
        {
            SetTemplate("account_group_edit");

            if (Owner.GetType() != typeof(UserGroup))
            {
                DisplayGenericError();
                return;
            }

            UserGroup thisGroup = (UserGroup)Owner;

            if (!thisGroup.IsGroupOperator(LoggedInMember.ItemKey))
            {
                core.Display.ShowMessage("Cannot Edit Group", "You must be an operator of the group to edit it.");
                return;
            }

            short category = thisGroup.RawCategory;

            SelectBox categoriesSelectBox = new SelectBox("category");
            DataTable categoriesTable = db.Query("SELECT category_id, category_title FROM global_categories ORDER BY category_title ASC;");
            foreach (DataRow categoryRow in categoriesTable.Rows)
            {
                categoriesSelectBox.Add(new SelectBoxItem(((long)categoryRow["category_id"]).ToString(), (string)categoryRow["category_title"]));
            }

            categoriesSelectBox.SelectedKey = category.ToString();
            template.Parse("S_CATEGORIES", categoriesSelectBox);
            template.Parse("S_GROUP_ID", thisGroup.GroupId.ToString());
            template.Parse("GROUP_DISPLAY_NAME", thisGroup.DisplayName);
            template.Parse("GROUP_DESCRIPTION", thisGroup.Description);

            string selected = "checked=\"checked\" ";
            switch (thisGroup.GroupType)
            {
                case "OPEN":
                    template.Parse("S_OPEN_CHECKED", selected);
                    break;
                case "REQUEST":
                    template.Parse("S_REQUEST_CHECKED", selected);
                    break;
                case "CLOSED":
                    template.Parse("S_CLOSED_CHECKED", selected);
                    break;
                case "PRIVATE":
                    template.Parse("S_PRIVATE_CHECKED", selected);
                    break;
            }

            DataTable pagesTable = db.Query(string.Format("SELECT page_id, page_slug, page_parent_path FROM user_pages WHERE page_item_id = {0} AND page_item_type_id = {1} ORDER BY page_order ASC;",
                thisGroup.Id, thisGroup.TypeId));

            SelectBox pagesSelectBox = new SelectBox("homepage");
            Dictionary<string, string> pages = new Dictionary<string, string>();
            List<string> disabledItems = new List<string>();
            pages.Add("/profile", "Group Profile");

            foreach (DataRow pageRow in pagesTable.Rows)
            {
                if (string.IsNullOrEmpty((string)pageRow["page_parent_path"]))
                {
                    pagesSelectBox.Add(new SelectBoxItem("/" + (string)pageRow["page_slug"], "/" + (string)pageRow["page_slug"] + "/"));
                }
                else
                {
                    pagesSelectBox.Add(new SelectBoxItem("/" + (string)pageRow["page_parent_path"] + "/" + (string)pageRow["page_slug"], "/" + (string)pageRow["page_parent_path"] + "/" + (string)pageRow["page_slug"] + "/"));
                }
            }

            pagesSelectBox.SelectedKey = thisGroup.GroupInfo.GroupHomepage.ToString();
            template.Parse("S_HOMEPAGE", pagesSelectBox);

            Save(new EventHandler(AccountGroupsEdit_Save));
        }
        void AccountProfileInfo_Show(object sender, EventArgs e)
        {
            SetTemplate("account_profile");

            RadioList genderRadioList = new RadioList("gender");
            genderRadioList.Add(new RadioListItem(genderRadioList.Name, ((byte)Gender.Undefined).ToString(), core.Prose.GetString("NONE_SPECIFIED")));
            genderRadioList.Add(new RadioListItem(genderRadioList.Name, ((byte)Gender.Male).ToString(), core.Prose.GetString("MALE")));
            genderRadioList.Add(new RadioListItem(genderRadioList.Name, ((byte)Gender.Female).ToString(), core.Prose.GetString("FEMALE")));
            genderRadioList.Add(new RadioListItem(genderRadioList.Name, ((byte)Gender.Intersex).ToString(), core.Prose.GetString("INTERSEX")));
            genderRadioList.SelectedKey = ((byte)LoggedInMember.Profile.GenderRaw).ToString();
            genderRadioList.Layout = Layout.Horizontal;

            TextBox heightTextBox = new TextBox("height");
            heightTextBox.MaxLength = 3;
            heightTextBox.Width = new StyleLength(3F, LengthUnits.Em);
            heightTextBox.Value = LoggedInMember.Profile.Height.ToString();

            SelectBox dobYearsSelectBox = new SelectBox("dob-year");

            for (int i = DateTime.Now.AddYears(-110).Year; i < DateTime.Now.AddYears(-13).Year; i++)
            {
                dobYearsSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            if (LoggedInMember.Profile.DateOfBirth != null)
            {
                dobYearsSelectBox.SelectedKey = LoggedInMember.Profile.DateOfBirth.Year.ToString();
            }

            SelectBox dobMonthsSelectBox = new SelectBox("dob-month");

            for (int i = 1; i < 13; i++)
            {
                dobMonthsSelectBox.Add(new SelectBoxItem(i.ToString(), core.Functions.IntToMonth(i)));
            }

            if (LoggedInMember.Profile.DateOfBirth != null)
            {
                dobMonthsSelectBox.SelectedKey = LoggedInMember.Profile.DateOfBirth.Month.ToString();
            }

            SelectBox dobDaysSelectBox = new SelectBox("dob-day");

            for (int i = 1; i < 32; i++)
            {
                dobDaysSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            if (LoggedInMember.Profile.DateOfBirth != null)
            {
                dobDaysSelectBox.SelectedKey = LoggedInMember.Profile.DateOfBirth.Day.ToString();
            }

            SelectBox countriesSelectBox = new SelectBox("country");

            SelectQuery query = new SelectQuery("countries");
            query.AddFields("*");
            query.AddSort(SortOrder.Ascending, "country_name");

            System.Data.Common.DbDataReader countriesReader = db.ReaderQuery(query);

            countriesSelectBox.Add(new SelectBoxItem("", "Unspecified"));

            while (countriesReader.Read())
            {
                countriesSelectBox.Add(new SelectBoxItem((string)countriesReader["country_iso"], (string)countriesReader["country_name"]));
            }

            countriesReader.Close();
            countriesReader.Dispose();

            if (LoggedInMember.Profile.CountryIso != null)
            {
                countriesSelectBox.SelectedKey = LoggedInMember.Profile.CountryIso;
            }

            template.Parse("S_GENDER", genderRadioList);

            template.Parse("S_DOB_YEAR", dobYearsSelectBox);
            template.Parse("S_DOB_MONTH", dobMonthsSelectBox);
            template.Parse("S_DOB_DAY", dobDaysSelectBox);
            template.Parse("S_COUNTRY", countriesSelectBox);
            template.Parse("S_HEIGHT", heightTextBox);

            template.Parse("S_AUTO_BIOGRAPHY", LoggedInMember.Profile.Autobiography);

            Save(new EventHandler(AccountProfileInfo_Save));
        }
        void AccountTourManage_Edit(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_tour_edit");

            Tour tour = null;

            /* */
            TextBox titleTextBox = new TextBox("title");
            titleTextBox.MaxLength = 127;

            /* */
            SelectBox yearSelectBox = new SelectBox("year");

            /* */
            TextBox abstractTextBox = new TextBox("abstract");
            abstractTextBox.Lines = 5;
            abstractTextBox.IsFormatted = true;

            for (int i = 1980; i < DateTime.UtcNow.Year + 5; i++)
            {
                yearSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            switch (e.Mode)
            {
                case "add":
                    yearSelectBox.SelectedKey = core.Tz.Now.Year.ToString();
                    break;
                case "edit":
                    long tourId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0));

                    try
                    {
                        tour = new Tour(core, tourId);
                    }
                    catch (InvalidTourException)
                    {
                        return;
                    }

                    titleTextBox.Value = tour.Title;
                    abstractTextBox.Value = tour.TourAbstract;

                    if (yearSelectBox.ContainsKey(tour.StartYear.ToString()))
                    {
                        yearSelectBox.SelectedKey = tour.StartYear.ToString();
                    }

                    if (core.Http.Form["title"] != null)
                    {
                        titleTextBox.Value = core.Http.Form["title"];
                    }
                    yearSelectBox.SelectedKey = core.Functions.FormShort("year", short.Parse(yearSelectBox.SelectedKey)).ToString();

                    template.Parse("S_ID", tour.Id.ToString());
                    template.Parse("EDIT", "TRUE");

                    break;
            }

            template.Parse("S_TITLE", titleTextBox);
            template.Parse("S_ABSTRACT", abstractTextBox);
            template.Parse("S_YEAR", yearSelectBox);

            SaveItemMode(AccountTourManage_EditSave, tour);
        }
        void AccountContactManage_EditAddress(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_address_edit");

            User user = LoggedInMember;

            /* */
            TextBox addressLine1TextBox = new TextBox("address-1");
            addressLine1TextBox.Value = user.Profile.AddressLine1;

            /* */
            TextBox addressLine2TextBox = new TextBox("address-2");
            addressLine2TextBox.Value = user.Profile.AddressLine2;

            /* */
            TextBox townTextBox = new TextBox("town");
            townTextBox.Value = user.Profile.AddressTown;

            /* */
            TextBox stateTextBox = new TextBox("state");
            stateTextBox.Value = user.Profile.AddressState;

            /* */
            TextBox postCodeTextBox = new TextBox("post-code");
            postCodeTextBox.MaxLength = 5;
            postCodeTextBox.Value = user.Profile.AddressPostCode;

            /* */
            SelectBox countrySelectBox = new SelectBox("country");

            List<Country> countries = new List<Country>();

            SelectQuery query = Item.GetSelectQueryStub(core, typeof(Country));
            query.AddSort(SortOrder.Ascending, "country_name");

            DataTable countryDataTable = db.Query(query);

            foreach (DataRow dr in countryDataTable.Rows)
            {
                countries.Add(new Country(core, dr));
            }

            foreach (Country country in countries)
            {
                countrySelectBox.Add(new SelectBoxItem(country.Iso, country.Name));
            }

            if (user.Profile.CountryIso != null)
            {
                countrySelectBox.SelectedKey = user.Profile.CountryIso;
            }

            template.Parse("S_ADDRESS_LINE_1", addressLine1TextBox);
            template.Parse("S_ADDRESS_LINE_2", addressLine2TextBox);
            template.Parse("S_TOWN", townTextBox);
            template.Parse("S_STATE", stateTextBox);
            template.Parse("S_POST_CODE", postCodeTextBox);
            template.Parse("S_COUNTRY", countrySelectBox);
        }
        public void ParseACL(Template template, Primitive owner, string variable)
        {
            Template aclTemplate = new Template("std.acl.html");
            aclTemplate.Medium = core.Template.Medium;
            aclTemplate.SetProse(core.Prose);

            if (itemPermissions == null)
            {
                itemPermissions = GetPermissions(core, item);
            }
            if (itemGrants == null)
            {
                itemGrants = AccessControlGrant.GetGrants(core, item);
            }
            if (unsavedGrants == null)
            {
                unsavedGrants = new List<UnsavedAccessControlGrant>();
            }

            if (itemGrants != null)
            {
                foreach (AccessControlGrant itemGrant in itemGrants)
                {
                    core.PrimitiveCache.LoadPrimitiveProfile(itemGrant.PrimitiveKey);
                }
            }

            bool simple = item.IsSimplePermissions;

            string mode = core.Http["aclmode"];
            switch (mode)
            {
                case "simple":
                    simple = true;
                    break;
                case "detailed":
                    simple = false;
                    break;
            }

            bool first = true;
            PermissionTypes lastType = PermissionTypes.View;
            VariableCollection permissionTypeVariableCollection = null;

            PermissionGroupSelectBox typeGroupSelectBox = null;
            List<PrimitivePermissionGroup> ownerGroups = null;

            if (itemPermissions != null)
            {
                foreach (AccessControlPermission itemPermission in itemPermissions)
                {
                    if (first || itemPermission.PermissionType != lastType)
                    {
                        if (typeGroupSelectBox != null)
                        {
                            permissionTypeVariableCollection.Parse("S_SIMPLE_SELECT", typeGroupSelectBox);
                        }

                        permissionTypeVariableCollection = aclTemplate.CreateChild("permision_types");
                        typeGroupSelectBox = new PermissionGroupSelectBox(core, "group-select-" + itemPermission.PermissionType.ToString(), item.ItemKey);

                        permissionTypeVariableCollection.Parse("TITLE", AccessControlLists.PermissionTypeToString(itemPermission.PermissionType));

                        first = false;
                        lastType = itemPermission.PermissionType;
                    }

                    if (simple)
                    {
                        if (ownerGroups == null)
                        {
                            ownerGroups = new List<PrimitivePermissionGroup>();
                            int itemGroups = 0;

                            Type type = item.GetType();
                            if (type.GetMethod(type.Name + "_GetItemGroups", new Type[] { typeof(Core) }) != null)
                            {
                                ownerGroups.AddRange((List<PrimitivePermissionGroup>)type.InvokeMember(type.Name + "_GetItemGroups", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, new object[] { core }));
                                itemGroups = ownerGroups.Count;
                            }

                            ownerGroups.AddRange(core.GetPrimitivePermissionGroups(owner));
                        }

                        VariableCollection permissionVariableCollection = permissionTypeVariableCollection.CreateChild("permission_desc");
                        permissionVariableCollection.Parse("ID", itemPermission.Id.ToString());
                        permissionVariableCollection.Parse("TITLE", itemPermission.Name);
                        permissionVariableCollection.Parse("DESCRIPTION", itemPermission.Description);

                        if (itemGrants != null)
                        {
                            foreach (AccessControlGrant itemGrant in itemGrants)
                            {
                                if (itemGrant.PermissionId == itemPermission.Id)
                                {
                                    switch (itemGrant.Allow)
                                    {
                                        case AccessControlGrants.Allow:
                                            PrimitivePermissionGroup ppg = null;

                                            ppg = new PrimitivePermissionGroup(itemGrant.PrimitiveKey, string.Empty, string.Empty);
                                            foreach (PrimitivePermissionGroup p in ownerGroups)
                                            {
                                                if (ppg.ItemKey.Equals(p.ItemKey))
                                                {
                                                    ppg = p;
                                                    break;
                                                }
                                            }

                                            if (!typeGroupSelectBox.ItemKeys.Contains(ppg))
                                            {
                                                typeGroupSelectBox.ItemKeys.Add(ppg);
                                            }
                                            break;
                                        default:
                                            break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        VariableCollection permissionVariableCollection = permissionTypeVariableCollection.CreateChild("permission");
                        permissionVariableCollection.Parse("ID", itemPermission.Id.ToString());
                        permissionVariableCollection.Parse("TITLE", itemPermission.Name);
                        permissionVariableCollection.Parse("DESCRIPTION", itemPermission.Description);

                        SelectBox groupsSelectBox = BuildGroupsSelectBox(string.Format("new-permission-group[{0}]", itemPermission.Id), owner);

                        if (itemGrants != null)
                        {
                            foreach (AccessControlGrant itemGrant in itemGrants)
                            {
                                if (itemGrant.PermissionId == itemPermission.Id)
                                {
                                    string gsbk = string.Format("{0},{1}", itemGrant.PrimitiveKey.TypeId, itemGrant.PrimitiveKey.Id);
                                    if (groupsSelectBox.ContainsKey(gsbk))
                                    {
                                        groupsSelectBox[gsbk].Selectable = false;
                                    }

                                    VariableCollection grantVariableCollection = permissionVariableCollection.CreateChild("grant");

                                    if (groupsSelectBox.ContainsKey(gsbk))
                                    {
                                        string text = groupsSelectBox[gsbk].Text;
                                        if (text.StartsWith(" -- ", StringComparison.Ordinal))
                                        {
                                            text = text.Substring(4);
                                        }
                                        grantVariableCollection.Parse("DISPLAY_NAME", text);
                                        groupsSelectBox[gsbk].Selectable = false;
                                    }
                                    else
                                    {
                                        try
                                        {
                                            grantVariableCollection.Parse("DISPLAY_NAME", core.PrimitiveCache[itemGrant.PrimitiveKey].DisplayName);
                                        }
                                        catch
                                        {
                                            grantVariableCollection.Parse("DISPLAY_NAME", "{{ERROR LOADING PRIMITIVE(" + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString() + ":" + (new ItemType(core, itemGrant.PrimitiveKey.TypeId)).Namespace + ")}}");
                                        }
                                    }

                                    RadioList allowrl = new RadioList("allow[" + itemGrant.PermissionId.ToString() + "," + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString() + "]");
                                    SelectBox allowsb = new SelectBox("allow[" + itemGrant.PermissionId.ToString() + "," + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString() + "]");
                                    Button deleteButton = new Button("delete", "Delete", itemGrant.PermissionId.ToString() + "," + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString());

                                    allowrl.Add(new RadioListItem(allowrl.Name, "allow", "Allow"));
                                    allowrl.Add(new RadioListItem(allowrl.Name, "deny", "Deny"));
                                    allowrl.Add(new RadioListItem(allowrl.Name, "inherit", "Inherit"));

                                    allowsb.Add(new SelectBoxItem("allow", "Allow"));
                                    allowsb.Add(new SelectBoxItem("deny", "Deny"));
                                    allowsb.Add(new SelectBoxItem("inherit", "Inherit"));

                                    switch (itemGrant.Allow)
                                    {
                                        case AccessControlGrants.Allow:
                                            allowrl.SelectedKey = "allow";
                                            allowsb.SelectedKey = "allow";
                                            break;
                                        case AccessControlGrants.Deny:
                                            allowrl.SelectedKey = "deny";
                                            allowsb.SelectedKey = "deny";
                                            break;
                                        case AccessControlGrants.Inherit:
                                            allowrl.SelectedKey = "inherit";
                                            allowsb.SelectedKey = "inherit";
                                            break;
                                    }

                                    if (core.Http.Form["allow[" + itemPermission.Id.ToString() + "," + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString() + "]"] != null)
                                    {
                                        allowrl.SelectedKey = core.Http.Form["allow[" + itemPermission.Id.ToString() + "," + itemGrant.PrimitiveKey.TypeId.ToString() + "," + itemGrant.PrimitiveKey.Id.ToString() + "]"];
                                    }

                                    grantVariableCollection.Parse("S_GRANT", allowsb);

                                    grantVariableCollection.Parse("S_ALLOW", allowrl["allow"]);
                                    grantVariableCollection.Parse("S_DENY", allowrl["deny"]);
                                    grantVariableCollection.Parse("S_INHERIT", allowrl["inherit"]);

                                    grantVariableCollection.Parse("S_DELETE", deleteButton);

                                    grantVariableCollection.Parse("ID", string.Format("{0},{1}", itemGrant.PrimitiveKey.TypeId, itemGrant.PrimitiveKey.Id));
                                    grantVariableCollection.Parse("PERMISSION_ID", itemPermission.Id.ToString());
                                    grantVariableCollection.Parse("IS_NEW", "FALSE");
                                }
                            }

                            foreach (AccessControlGrant itemGrant in itemGrants)
                            {
                                VariableCollection grantsVariableCollection = template.CreateChild("grants");
                            }
                        }

                        if (core.Http.Form["save"] == null)
                        {
                            foreach (SelectBoxItem gsbi in groupsSelectBox)
                            {
                                if (core.Http.Form[string.Format("new-grant[{0},{1}]", itemPermission.Id, gsbi.Key)] != null)
                                {
                                    ItemKey ik = new ItemKey(gsbi.Key);

                                    UnsavedAccessControlGrant uacg = new UnsavedAccessControlGrant(core, ik, item.ItemKey, itemPermission.Id, AccessControlGrants.Inherit);

                                    VariableCollection grantVariableCollection = permissionVariableCollection.CreateChild("grant");

                                    grantVariableCollection.Parse("DISPLAY_NAME", gsbi.Text);

                                    RadioList allowrl = new RadioList("allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]");
                                    SelectBox allowsb = new SelectBox("allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]");

                                    allowrl.Add(new RadioListItem(allowrl.Name, "allow", "Allow"));
                                    allowrl.Add(new RadioListItem(allowrl.Name, "deny", "Deny"));
                                    allowrl.Add(new RadioListItem(allowrl.Name, "inherit", "Inherit"));

                                    allowsb.Add(new SelectBoxItem("allow", "Allow"));
                                    allowsb.Add(new SelectBoxItem("deny", "Deny"));
                                    allowsb.Add(new SelectBoxItem("inherit", "Inherit"));

                                    if (core.Http.Form["allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]"] != null)
                                    {
                                        allowrl.SelectedKey = core.Http.Form["allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]"];
                                    }
                                    else
                                    {
                                        switch (uacg.Allow)
                                        {
                                            case AccessControlGrants.Allow:
                                                allowrl.SelectedKey = "allow";
                                                allowsb.SelectedKey = "allow";
                                                break;
                                            case AccessControlGrants.Deny:
                                                allowrl.SelectedKey = "deny";
                                                allowsb.SelectedKey = "deny";
                                                break;
                                            case AccessControlGrants.Inherit:
                                                allowrl.SelectedKey = "inherit";
                                                allowsb.SelectedKey = "inherit";
                                                break;
                                        }
                                    }

                                    grantVariableCollection.Parse("S_GRANT", allowsb);

                                    grantVariableCollection.Parse("S_ALLOW", allowrl["allow"]);
                                    grantVariableCollection.Parse("S_DENY", allowrl["deny"]);
                                    grantVariableCollection.Parse("S_INHERIT", allowrl["inherit"]);

                                    grantVariableCollection.Parse("ID", string.Format("{0},{1}", ik.TypeId, ik.Id));
                                    grantVariableCollection.Parse("PERMISSION_ID", itemPermission.Id.ToString());
                                    grantVariableCollection.Parse("IS_NEW", "TRUE");

                                    gsbi.Selectable = false;
                                }
                            }
                        }

                        if (core.Http.Form[string.Format("add-permission[{0}]", itemPermission.Id)] != null)
                        {
                            string groupSelectBoxId = core.Http.Form[string.Format("new-permission-group[{0}]", itemPermission.Id)];

                            ItemKey ik = new ItemKey(groupSelectBoxId);

                            UnsavedAccessControlGrant uacg = new UnsavedAccessControlGrant(core, ik, item.ItemKey, itemPermission.Id, AccessControlGrants.Inherit);

                            VariableCollection grantVariableCollection = permissionVariableCollection.CreateChild("grant");

                            grantVariableCollection.Parse("DISPLAY_NAME", groupsSelectBox[groupSelectBoxId].Text);

                            RadioList allowrl = new RadioList("allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]");
                            SelectBox allowsb = new SelectBox("allow[" + itemPermission.Id.ToString() + "," + ik.TypeId.ToString() + "," + ik.Id.ToString() + "]");

                            allowrl.Add(new RadioListItem(allowrl.Name, "allow", "Allow"));
                            allowrl.Add(new RadioListItem(allowrl.Name, "deny", "Deny"));
                            allowrl.Add(new RadioListItem(allowrl.Name, "inherit", "Inherit"));

                            allowsb.Add(new SelectBoxItem("allow", "Allow"));
                            allowsb.Add(new SelectBoxItem("deny", "Deny"));
                            allowsb.Add(new SelectBoxItem("inherit", "Inherit"));

                            switch (uacg.Allow)
                            {
                                case AccessControlGrants.Allow:
                                    allowrl.SelectedKey = "allow";
                                    allowsb.SelectedKey = "allow";
                                    break;
                                case AccessControlGrants.Deny:
                                    allowrl.SelectedKey = "deny";
                                    allowsb.SelectedKey = "deny";
                                    break;
                                case AccessControlGrants.Inherit:
                                    allowrl.SelectedKey = "inherit";
                                    allowsb.SelectedKey = "inherit";
                                    break;
                            }

                            grantVariableCollection.Parse("S_GRANT", allowsb);

                            grantVariableCollection.Parse("S_ALLOW", allowrl["allow"]);
                            grantVariableCollection.Parse("S_DENY", allowrl["deny"]);
                            grantVariableCollection.Parse("S_INHERIT", allowrl["inherit"]);

                            grantVariableCollection.Parse("ID", string.Format("{0},{1}", ik.TypeId, ik.Id));
                            grantVariableCollection.Parse("PERMISSION_ID", itemPermission.Id.ToString());
                            grantVariableCollection.Parse("IS_NEW", "TRUE");

                            groupsSelectBox[groupSelectBoxId].Selectable = false;
                        }

                        permissionVariableCollection.Parse("S_PERMISSION_GROUPS", groupsSelectBox);

                        RadioList allowNewrl = new RadioList("new-permission-group-allow");
                        SelectBox allowNewsb = new SelectBox("new-permission-group-allow");

                        allowNewrl.Add(new RadioListItem(allowNewrl.Name, "allow", "Allow"));
                        allowNewrl.Add(new RadioListItem(allowNewrl.Name, "deny", "Deny"));
                        allowNewrl.Add(new RadioListItem(allowNewrl.Name, "inherit", "Inherit"));

                        allowNewsb.Add(new SelectBoxItem("allow", "Allow"));
                        allowNewsb.Add(new SelectBoxItem("deny", "Deny"));
                        allowNewsb.Add(new SelectBoxItem("inherit", "Inherit"));

                        allowNewrl.SelectedKey = "inherit";
                        allowNewsb.SelectedKey = "inherit";

                        permissionVariableCollection.Parse("S_GRANT", allowNewsb);

                        permissionVariableCollection.Parse("S_ALLOW", allowNewrl["allow"].ToString());
                        permissionVariableCollection.Parse("S_DENY", allowNewrl["deny"].ToString());
                        permissionVariableCollection.Parse("S_INHERIT", allowNewrl["inherit"].ToString());
                    }
                }

                if (typeGroupSelectBox != null)
                {
                    permissionTypeVariableCollection.Parse("S_SIMPLE_SELECT", typeGroupSelectBox);
                }
            }

            if (string.IsNullOrEmpty(variable))
            {
                variable = "S_PERMISSIONS";
            }

            /*PermissionGroupSelectBox groupSelectBox = new PermissionGroupSelectBox(core, "group-select", item.ItemKey);
            groupSelectBox.SelectMultiple = true;

            aclTemplate.Parse("S_SIMPLE_SELECT", groupSelectBox);*/

            if (simple)
            {
                aclTemplate.Parse("IS_SIMPLE", "TRUE");
            }

            aclTemplate.Parse("U_DETAILED", Access.BuildAclUri(core, item, false));
            aclTemplate.Parse("U_SIMPLE", Access.BuildAclUri(core, item, true));

            HiddenField modeField = new HiddenField("aclmode");
            if (simple)
            {
                modeField.Value = "simple";
            }
            else
            {
                modeField.Value = "detailed";
            }

            aclTemplate.Parse("S_ACLMODE", modeField);

            template.ParseRaw(variable, aclTemplate.ToString());
        }
Beispiel #8
0
        public static SelectBox BuildTimeZoneSelectBox(string name)
        {
            SelectBox currencySelectBox = new SelectBox(name);

            currencySelectBox.Add(new SelectBoxItem(GetCurrencyId("AUD").ToString(), " Australian Dollar (AUD)"));
            currencySelectBox.Add(new SelectBoxItem(GetCurrencyId("CAD").ToString(), " Canadian dollar (CAD)"));
            currencySelectBox.Add(new SelectBoxItem(GetCurrencyId("CHF").ToString(), " Swiss franc (CHF)"));
            currencySelectBox.Add(new SelectBoxItem(GetCurrencyId("CNY").ToString(), " Chinese yuan (CNY)"));
            currencySelectBox.Add(new SelectBoxItem(GetCurrencyId("EUR").ToString(), " Euro (EUR)"));
            currencySelectBox.Add(new SelectBoxItem(GetCurrencyId("GBP").ToString(), " Pound Sterling (GBP)"));
            currencySelectBox.Add(new SelectBoxItem(GetCurrencyId("HKD").ToString(), " Hong Kong dollar (HKD)"));
            currencySelectBox.Add(new SelectBoxItem(GetCurrencyId("JPY").ToString(), " Japanese Yen (JPY)"));
            currencySelectBox.Add(new SelectBoxItem(GetCurrencyId("NZD").ToString(), " New Zealand dollar (NZD)"));
            currencySelectBox.Add(new SelectBoxItem(GetCurrencyId("SEK").ToString(), " Swedish krona (SEK)"));
            currencySelectBox.Add(new SelectBoxItem(GetCurrencyId("USD").ToString(), " United States dollar (USD)"));

            return currencySelectBox;
        }
        void AccountPreferences_Show(object sender, EventArgs e)
        {
            Save(new EventHandler(AccountPreferences_Save));

            //User loggedInMember = (User)loggedInMember;
            template.SetTemplate("account_preferences.html");

            TextBox customDomainTextBox = new TextBox("custom-domain");
            customDomainTextBox.Value = LoggedInMember.UserDomain;

            TextBox analyticsCodeTextBox = new TextBox("analytics-code");
            analyticsCodeTextBox.Value = LoggedInMember.UserInfo.AnalyticsCode;

            TextBox twitterUserNameTextBox = new TextBox("twitter-user-name");
            twitterUserNameTextBox.Value = LoggedInMember.UserInfo.TwitterUserName;

            CheckBox twitterSyndicateCheckBox = new CheckBox("twitter-syndicate");
            twitterSyndicateCheckBox.IsChecked = LoggedInMember.UserInfo.TwitterSyndicate;
            twitterSyndicateCheckBox.Width.Length = 0;

            CheckBox tumblrSyndicateCheckBox = new CheckBox("tumblr-syndicate");
            tumblrSyndicateCheckBox.IsChecked = LoggedInMember.UserInfo.TumblrSyndicate;
            tumblrSyndicateCheckBox.Width.Length = 0;

            CheckBox facebookSyndicateCheckBox = new CheckBox("facebook-syndicate");
            facebookSyndicateCheckBox.IsChecked = LoggedInMember.UserInfo.FacebookSyndicate;
            facebookSyndicateCheckBox.Width.Length = 0;

            SelectBox facebookSharePermissionSelectBox = new SelectBox("facebook-share-permissions");
            facebookSharePermissionSelectBox.Add(new SelectBoxItem("", core.Prose.GetString("TIMELINE_DEFAULT")));
            facebookSharePermissionSelectBox.Add(new SelectBoxItem("EVERYONE", core.Prose.GetString("PUBLIC")));
            facebookSharePermissionSelectBox.Add(new SelectBoxItem("FRIENDS_OF_FRIENDS", core.Prose.GetString("FRIENDS_OF_FACEBOOK_FRIENDS")));
            facebookSharePermissionSelectBox.Add(new SelectBoxItem("ALL_FRIENDS", core.Prose.GetString("FACEBOOK_FRIENDS")));

            SelectBox tumblrBlogsSelectBox = new SelectBox("tumblr-blogs");
            if (LoggedInMember.UserInfo.TumblrAuthenticated)
            {
                Tumblr t = new Tumblr(core.Settings.TumblrApiKey, core.Settings.TumblrApiSecret);
                List<Dictionary<string, string>> blogs = t.GetUserInfo(new TumblrAccessToken(LoggedInMember.UserInfo.TumblrToken, LoggedInMember.UserInfo.TumblrTokenSecret)).Blogs;

                foreach (Dictionary<string, string> blog in blogs)
                {
                    string hostname = (new Uri(blog["url"])).Host;
                    tumblrBlogsSelectBox.Add(new SelectBoxItem(hostname, blog["title"]));

                    if (hostname == LoggedInMember.UserInfo.TumblrHostname)
                    {
                        tumblrBlogsSelectBox.SelectedKey = LoggedInMember.UserInfo.TumblrHostname;
                    }
                }
            }

            if (LoggedInMember.UserInfo.FacebookSharePermissions != null)
            {
                facebookSharePermissionSelectBox.SelectedKey = LoggedInMember.UserInfo.FacebookSharePermissions;
            }

            string radioChecked = " checked=\"checked\"";

            if (LoggedInMember.UserInfo.EmailNotifications)
            {
                template.Parse("S_EMAIL_NOTIFICATIONS_YES", radioChecked);
            }
            else
            {
                template.Parse("S_EMAIL_NOTIFICATIONS_NO", radioChecked);
            }

            if (LoggedInMember.UserInfo.ShowCustomStyles)
            {
                template.Parse("S_SHOW_STYLES_YES", radioChecked);
            }
            else
            {
                template.Parse("S_SHOW_STYLES_NO", radioChecked);
            }

            if (LoggedInMember.UserInfo.BbcodeShowImages)
            {
                template.Parse("S_DISPLAY_IMAGES_YES", radioChecked);
            }
            else
            {
                template.Parse("S_DISPLAY_IMAGES_NO", radioChecked);
            }

            if (LoggedInMember.UserInfo.BbcodeShowFlash)
            {
                template.Parse("S_DISPLAY_FLASH_YES", radioChecked);
            }
            else
            {
                template.Parse("S_DISPLAY_FLASH_NO", radioChecked);
            }

            if (LoggedInMember.UserInfo.BbcodeShowVideos)
            {
                template.Parse("S_DISPLAY_VIDEOS_YES", radioChecked);
            }
            else
            {
                template.Parse("S_DISPLAY_VIDEOS_NO", radioChecked);
            }

            template.Parse("S_CUSTOM_DOMAIN", customDomainTextBox);
            template.Parse("S_ANALYTICS_CODE", analyticsCodeTextBox);

            if (!string.IsNullOrEmpty(core.Settings.TwitterApiKey))
            {
                template.Parse("S_TWITTER_INTEGRATION", "TRUE");
            }

            if (!string.IsNullOrEmpty(core.Settings.TumblrApiKey))
            {
                template.Parse("S_TUMBLR_INTEGRATION", "TRUE");
            }

            if (core.Settings.FacebookEnabled || ((!string.IsNullOrEmpty(core.Settings.FacebookApiAppid)) && LoggedInMember.UserInfo.FacebookAuthenticated))
            {
                template.Parse("S_FACEBOOK_INTEGRATION", "TRUE");
            }

            if (string.IsNullOrEmpty(LoggedInMember.UserInfo.TwitterUserName))
            {
                template.Parse("S_TWITTER_USER_NAME", twitterUserNameTextBox);
            }
            else
            {
                template.Parse("TWITTER_USER_NAME", LoggedInMember.UserInfo.TwitterUserName);
                template.Parse("S_SYDNDICATE_TWITTER", twitterSyndicateCheckBox);
                template.Parse("U_UNLINK_TWITTER", core.Hyperlink.AppendSid(BuildUri("preferences", "unlink-twitter"), true));
            }

            if (string.IsNullOrEmpty(LoggedInMember.UserInfo.TumblrUserName))
            {
                template.Parse("U_LINK_TUMBLR", core.Hyperlink.AppendSid(BuildUri("preferences", "link-tumblr"), true));
            }
            else
            {
                /* TODO: get list of tumblr blogs */

                template.Parse("TUMBLR_USER_NAME", LoggedInMember.UserInfo.TumblrUserName);
                template.Parse("S_TUMBLR_BLOGS", tumblrBlogsSelectBox);
                template.Parse("S_SYDNDICATE_TUMBLR", tumblrSyndicateCheckBox);
                template.Parse("U_UNLINK_TUMBLR", core.Hyperlink.AppendSid(BuildUri("preferences", "unlink-tumblr"), true));
            }

            if (string.IsNullOrEmpty(LoggedInMember.UserInfo.FacebookUserId))
            {
                string appId = core.Settings.FacebookApiAppid;
                string redirectTo = (core.Settings.UseSecureCookies ? "https://" : "http://") + Hyperlink.Domain + "/api/facebook/callback";

                template.Parse("U_LINK_FACEBOOK", string.Format("https://www.facebook.com/dialog/oauth?client_id={0}&redirect_uri={1}&scope={2}", appId, System.Web.HttpUtility.UrlEncode(redirectTo), "publish_actions"));
            }
            else
            {
                template.Parse("S_SYDNDICATE_FACEBOOK", facebookSyndicateCheckBox);
                template.Parse("S_FACEBOOK_SHARE_PERMISSIONS", facebookSharePermissionSelectBox);
                template.Parse("U_UNLINK_FACEBOOK", core.Hyperlink.AppendSid(BuildUri("preferences", "unlink-facebook"), true));
            }

            DataTable pagesTable = db.Query(string.Format("SELECT page_id, page_slug, page_parent_path FROM user_pages WHERE page_item_id = {0} AND page_item_type_id = {1} ORDER BY page_order ASC;",
                LoggedInMember.UserId, ItemKey.GetTypeId(core, typeof(User))));

            SelectBox pagesSelectBox = new SelectBox("homepage");

            foreach (DataRow pageRow in pagesTable.Rows)
            {
                if (string.IsNullOrEmpty((string)pageRow["page_parent_path"]))
                {
                    pagesSelectBox.Add(new SelectBoxItem("/" + (string)pageRow["page_slug"], "/" + (string)pageRow["page_slug"]));
                }
                else
                {
                    pagesSelectBox.Add(new SelectBoxItem("/" + (string)pageRow["page_parent_path"] + "/" + (string)pageRow["page_slug"], "/" + (string)pageRow["page_parent_path"] + "/" + (string)pageRow["page_slug"]));
                }
            }

            SelectBox timezoneSelectBox = UnixTime.BuildTimeZoneSelectBox("timezone");
            timezoneSelectBox.SelectedKey = LoggedInMember.UserInfo.TimeZoneCode.ToString();

            pagesSelectBox.SelectedKey = LoggedInMember.UserInfo.ProfileHomepage;
            template.Parse("S_HOMEPAGE", pagesSelectBox);
            template.Parse("S_TIMEZONE", timezoneSelectBox);
            //core.Display.ParseTimeZoneBox(template, "S_TIMEZONE", LoggedInMember.TimeZoneCode.ToString());

            if (core.Http.Query["status"] == "facebook-auth-failed")
            {
                DisplayError("Failed to link your Facebook profile");
            }
        }
Beispiel #10
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);
        }
        void AccountPagesWrite_Show(object sender, EventArgs e)
        {
            SetTemplate("account_write");

            VariableCollection javaScriptVariableCollection = core.Template.CreateChild("javascript_list");
            javaScriptVariableCollection.Parse("URI", @"/scripts/jquery.sceditor.bbcode.min.js");

            VariableCollection styleSheetVariableCollection = core.Template.CreateChild("style_sheet_list");
            styleSheetVariableCollection.Parse("URI", @"/styles/jquery.sceditor.theme.default.min.css");

            core.Template.Parse("OWNER_STUB", Owner.UriStubAbsolute);

            long pageId = 0;
            long pageParentId = 0;
            byte licenseId = 0;
            ushort pagePermissions = 4369;
            string pageTitle = (core.Http.Form["title"] != null) ? core.Http.Form["title"] : "";
            string pageSlug = (core.Http.Form["slug"] != null) ? core.Http.Form["slug"] : "";
            string pageText = (core.Http.Form["post"] != null) ? core.Http.Form["post"] : "";
            string pagePath = "";
            Classifications pageClassification = Classifications.Everyone;

            try
            {
                if (core.Http.Form["license"] != null)
                {
                    licenseId = core.Functions.GetLicenseId();
                }
                if (core.Http.Form["id"] != null)
                {
                    pageId = long.Parse(core.Http.Form["id"]);
                }
                if (core.Http.Form["page-parent"] != null)
                {
                    pageParentId = long.Parse(core.Http.Form["page-parent"]);
                }
            }
            catch
            {
            }

            if (core.Http.Query["id"] != null)
            {
                try
                {
                    pageId = long.Parse(core.Http.Query["id"]);
                }
                catch
                {
                }
            }

            if (pageId > 0)
            {
                if (core.Http.Query["mode"] == "edit")
                {
                    try
                    {
                        Page page = new Page(core, Owner, pageId);

                        pageParentId = page.ParentId;
                        pageTitle = page.Title;
                        pageSlug = page.Slug;
                        //pagePermissions = page.Permissions;
                        licenseId = page.LicenseId;
                        pageText = page.Body;
                        pagePath = page.FullPath;
                        pageClassification = page.Classification;
                    }
                    catch (PageNotFoundException)
                    {
                        DisplayGenericError();
                    }
                }
            }

            Pages myPages = new Pages(core, Owner);
            List<Page> pagesList = myPages.GetPages(false, true);

            SelectBox pagesSelectBox = new SelectBox("page-parent");
            pagesSelectBox.Add(new SelectBoxItem("0", "/"));

            foreach (Page page in pagesList)
            {
                SelectBoxItem item = new SelectBoxItem(page.Id.ToString(), page.FullPath);
                pagesSelectBox.Add(item);

                if (pageId > 0)
                {
                    if (page.FullPath.StartsWith(pagePath, StringComparison.Ordinal))
                    {
                        item.Selectable = false;
                    }
                }
            }

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

            if (pageId > 0 && pagesSelectBox.ContainsKey(pageId.ToString()))
            {
                pagesSelectBox[pageId.ToString()].Selectable = false;
            }

            pagesSelectBox.SelectedKey = pageParentId.ToString();

            core.Display.ParseLicensingBox(template, "S_PAGE_LICENSE", licenseId);
            core.Display.ParseClassification(template, "S_PAGE_CLASSIFICATION", pageClassification);
            template.Parse("S_PAGE_PARENT", pagesSelectBox);

            //core.Display.ParsePermissionsBox(template, "S_PAGE_PERMS", pagePermissions, permissions);

            template.Parse("S_TITLE", pageTitle);
            template.Parse("S_SLUG", pageSlug);
            template.Parse("S_PAGE_TEXT", pageText);
            template.Parse("S_ID", pageId.ToString());

            Save(new EventHandler(AccountPagesWrite_Save));
            if (core.Http.Form["publish"] != null)
            {
                AccountPagesWrite_Save(this, new EventArgs());
            }
        }
Beispiel #12
0
        public static SelectBox BuildForumJumpBox(Core core, Primitive owner, long currentForum)
        {
            SelectBox sb = new SelectBox("forum");

            sb.Add(new SelectBoxItem("", core.Prose.GetString("SELECT_A_FORUM")));
            sb.Add(new SelectBoxItem("", "--------------------"));

            SelectQuery query = Item.GetSelectQueryStub(core, typeof(Forum));
            query.AddCondition("forum_item_id", owner.Id);
            query.AddCondition("forum_item_type_id", owner.TypeId);
            query.AddSort(SortOrder.Ascending, "forum_order");

            DataTable forumsTable = core.Db.Query(query);

            foreach (DataRow dr in forumsTable.Rows)
            {
                Forum forum;
                if (owner is UserGroup)
                {
                    forum = new Forum(core, (UserGroup)owner, dr);
                }
                else
                {
                    forum = new Forum(core, dr);
                }
                if (forum != null)
                {
                    if (forum.Access.Can("VIEW"))
                    {
                        sb.Add(new SelectBoxItem(forum.Id.ToString(), forum.Title));
                    }
                }
            }

            if (sb.ContainsKey(currentForum.ToString()))
            {
                sb.SelectedKey = currentForum.ToString();
            }

            return sb;
        }
        void AccountListsManage_Show(object sender, EventArgs e)
        {
            SetTemplate("account_lists");

            ushort listPermissions = 0x1111;

            SelectQuery query = List.GetSelectQueryStub(core, typeof(List));
            query.AddCondition("user_id", Owner.Id);
            DataTable listsTable = db.Query(query);

            for (int i = 0; i < listsTable.Rows.Count; i++)
            {
                List l = new List(core, (User)Owner, listsTable.Rows[i]);
                VariableCollection listVariableCollection = template.CreateChild("list_list");

                listVariableCollection.Parse("TITLE", l.Title);
                listVariableCollection.Parse("TYPE", l.Type.ToString());
                listVariableCollection.Parse("ITEMS", core.Functions.LargeIntegerToString(l.Items));

                listVariableCollection.Parse("U_VIEW", core.Hyperlink.BuildListUri(LoggedInMember, l.Path));
                listVariableCollection.Parse("U_DELETE", core.Hyperlink.BuildDeleteListUri(l.Id));
                listVariableCollection.Parse("U_PERMISSIONS", l.Access.AclUri);
                listVariableCollection.Parse("U_EDIT", core.Hyperlink.BuildEditListUri(l.Id));
            }

            DataTable listTypesTable = db.Query("SELECT list_type_id, list_type_title FROM list_types ORDER BY list_type_title ASC");

            SelectBox listTypesSelectBox = new SelectBox("type");

            for (int i = 0; i < listTypesTable.Rows.Count; i++)
            {
                listTypesSelectBox.Add(new SelectBoxItem(((long)listTypesTable.Rows[i]["list_type_id"]).ToString(),
                    (string)listTypesTable.Rows[i]["list_type_title"]));
            }

            listTypesSelectBox.SelectedKey = "1";

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

            template.Parse("S_LIST_TYPES", listTypesSelectBox);
            //core.Display.ParsePermissionsBox(template, "S_LIST_PERMS", listPermissions, permissions);

            Save(new EventHandler(AccountListsManage_Save));
        }
        /// <summary>
        /// Edit a list
        /// </summary>
        void AccountListsManage_Edit(object sender, EventArgs e)
        {
            long listId = core.Functions.RequestLong("id", 0);

            SetTemplate("account_list_edit");

            try
            {
                List list = new List(core, session.LoggedInMember, listId);

                if (!list.Access.Can("EDIT"))
                {
                    DisplayGenericError();
                    return;
                }

                DataTable listTypesTable = db.Query("SELECT list_type_id, list_type_title FROM list_types ORDER BY list_type_title ASC");

                SelectBox listTypesSelectBox = new SelectBox("type");

                for (int i = 0; i < listTypesTable.Rows.Count; i++)
                {
                    listTypesSelectBox.Add(new SelectBoxItem(((long)listTypesTable.Rows[i]["list_type_id"]).ToString(),
                        (string)listTypesTable.Rows[i]["list_type_title"]));
                }

                listTypesSelectBox.SelectedKey = list.Type.ToString();

                template.Parse("S_LIST_TYPES", listTypesSelectBox);
                //core.Display.ParsePermissionsBox(template, "S_LIST_PERMS", list.Permissions, list.PermissibleActions);

                template.Parse("S_LIST_TITLE", list.Title);
                template.Parse("S_LIST_SLUG", list.Path);
                template.Parse("S_LIST_ABSTRACT", list.Abstract);

                template.Parse("S_LIST_ID", list.Id.ToString());
            }
            catch (InvalidListException)
            {
                core.Display.ShowMessage("List Error", "You submitted invalid information. Go back and try again. List may have already been deleted.");
                return;
            }
        }
Beispiel #15
0
        public Template GetPostTemplate(Core core, Primitive owner)
        {
            Template template = new Template(Assembly.GetExecutingAssembly(), "postblog");
            template.Medium = core.Template.Medium;
            template.SetProse(core.Prose);

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

            template.Parse("USER_DISPLAY_NAME", owner.DisplayName);

            Blog blog = null;

            try
            {
                blog = new Blog(core, (User)owner);
            }
            catch (InvalidBlogException)
            {
                if (owner.ItemKey.Equals(core.LoggedInMemberItemKey))
                {
                    blog = Blog.Create(core);
                }
                else
                {
                    return null;
                }
            }

            /* Title TextBox */
            TextBox titleTextBox = new TextBox("title");
            titleTextBox.MaxLength = 127;

            /* Post TextBox */
            TextBox postTextBox = new TextBox("post");
            postTextBox.IsFormatted = true;
            postTextBox.Lines = 15;

            /* Tags TextBox */
            TagSelectBox tagsTextBox = new TagSelectBox(core, "tags");
            //tagsTextBox.MaxLength = 127;

            CheckBox publishToFeedCheckBox = new CheckBox("publish-feed");
            publishToFeedCheckBox.IsChecked = true;

            PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", blog.ItemKey);
            HiddenField aclModeField = new HiddenField("aclmode");
            aclModeField.Value = "simple";

            template.Parse("S_PERMISSIONS", permissionSelectBox);
            template.Parse("S_ACLMODE", aclModeField);

            DateTime postTime = DateTime.Now;

            SelectBox postYearsSelectBox = new SelectBox("post-year");
            for (int i = DateTime.Now.AddYears(-7).Year; i <= DateTime.Now.Year; i++)
            {
                postYearsSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            postYearsSelectBox.SelectedKey = postTime.Year.ToString();

            SelectBox postMonthsSelectBox = new SelectBox("post-month");
            for (int i = 1; i < 13; i++)
            {
                postMonthsSelectBox.Add(new SelectBoxItem(i.ToString(), core.Functions.IntToMonth(i)));
            }

            postMonthsSelectBox.SelectedKey = postTime.Month.ToString();

            SelectBox postDaysSelectBox = new SelectBox("post-day");
            for (int i = 1; i < 32; i++)
            {
                postDaysSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            postDaysSelectBox.SelectedKey = postTime.Day.ToString();

            template.Parse("S_POST_YEAR", postYearsSelectBox);
            template.Parse("S_POST_MONTH", postMonthsSelectBox);
            template.Parse("S_POST_DAY", postDaysSelectBox);
            template.Parse("S_POST_HOUR", postTime.Hour.ToString());
            template.Parse("S_POST_MINUTE", postTime.Minute.ToString());

            SelectBox licensesSelectBox = new SelectBox("license");
            System.Data.Common.DbDataReader licensesReader = core.Db.ReaderQuery(ContentLicense.GetSelectQueryStub(core, typeof(ContentLicense)));

            licensesSelectBox.Add(new SelectBoxItem("0", "Default License"));
            while(licensesReader.Read())
            {
                ContentLicense li = new ContentLicense(core, licensesReader);
                licensesSelectBox.Add(new SelectBoxItem(li.Id.ToString(), li.Title));
            }

            licensesReader.Close();
            licensesReader.Dispose();

            SelectBox categoriesSelectBox = new SelectBox("category");
            SelectQuery query = Category.GetSelectQueryStub(core, typeof(Category));
            query.AddSort(SortOrder.Ascending, "category_title");

            System.Data.Common.DbDataReader categoriesReader = core.Db.ReaderQuery(query);

            while (categoriesReader.Read())
            {
                Category cat = new Category(core, categoriesReader);
                categoriesSelectBox.Add(new SelectBoxItem(cat.Id.ToString(), cat.Title));
            }

            categoriesReader.Close();
            categoriesReader.Dispose();

            categoriesSelectBox.SelectedKey = 1.ToString();

            /* Parse the form fields */
            template.Parse("S_TITLE", titleTextBox);
            template.Parse("S_BLOG_TEXT", postTextBox);
            template.Parse("S_TAGS", tagsTextBox);

            template.Parse("S_BLOG_LICENSE", licensesSelectBox);
            template.Parse("S_BLOG_CATEGORY", categoriesSelectBox);

            template.Parse("S_PUBLISH_FEED", publishToFeedCheckBox);

            return template;
        }
Beispiel #16
0
        void PostContent(HookEventArgs e)
        {
            VariableCollection styleSheetVariableCollection = core.Template.CreateChild("javascript_list");
            styleSheetVariableCollection.Parse("URI", @"/scripts/load-image.min.js");
            styleSheetVariableCollection = core.Template.CreateChild("javascript_list");
            styleSheetVariableCollection.Parse("URI", @"/scripts/canvas-to-blob.min.js");

            styleSheetVariableCollection = core.Template.CreateChild("javascript_list");
            styleSheetVariableCollection.Parse("URI", @"/scripts/jquery.iframe-transport.js");
            styleSheetVariableCollection = core.Template.CreateChild("javascript_list");
            styleSheetVariableCollection.Parse("URI", @"/scripts/jquery.fileupload.js");
            styleSheetVariableCollection = core.Template.CreateChild("javascript_list");
            styleSheetVariableCollection.Parse("URI", @"/scripts/jquery.fileupload-process.js");
            styleSheetVariableCollection = core.Template.CreateChild("javascript_list");
            styleSheetVariableCollection.Parse("URI", @"/scripts/jquery.fileupload-image.js");

            if (e.core.IsMobile)
            {
                return;
            }

            Template template = new Template(Assembly.GetExecutingAssembly(), "postphoto");
            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);

            template.Parse("USER_DISPLAY_NAME", e.Owner.DisplayName);

            CheckBox publishToFeedCheckBox = new CheckBox("publish-feed");
            publishToFeedCheckBox.IsChecked = true;

            CheckBox highQualityCheckBox = new CheckBox("high-quality");
            highQualityCheckBox.IsChecked = false;

            core.Display.ParseLicensingBox(template, "S_GALLERY_LICENSE", 0);

            template.Parse("S_PUBLISH_FEED", publishToFeedCheckBox);
            template.Parse("S_HIGH_QUALITY", highQualityCheckBox);

            core.Display.ParseClassification(template, "S_PHOTO_CLASSIFICATION", Classifications.Everyone);

            PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", e.Owner.ItemKey);
            HiddenField aclModeField = new HiddenField("aclmode");
            aclModeField.Value = "simple";

            template.Parse("S_PERMISSIONS", permissionSelectBox);
            template.Parse("S_ACLMODE", aclModeField);

            //GallerySettings settings = new GallerySettings(core, e.Owner);
            Gallery rootGallery = new Gallery(core, e.Owner);
            List<Gallery> galleries = rootGallery.GetGalleries();

            SelectBox galleriesSelectBox = new SelectBox("gallery-id");

            foreach (Gallery gallery in galleries)
            {
                galleriesSelectBox.Add(new SelectBoxItem(gallery.Id.ToString(), gallery.GalleryTitle));
            }

            template.Parse("S_GALLERIES", galleriesSelectBox);

            /* Title TextBox */
            TextBox galleryTitleTextBox = new TextBox("gallery-title");
            galleryTitleTextBox.MaxLength = 127;

            template.Parse("S_GALLERY_TITLE", galleryTitleTextBox);

            CheckBoxArray shareCheckBoxArray = new CheckBoxArray("share-radio");
            shareCheckBoxArray.Layout = Layout.Horizontal;
            CheckBox twitterSyndicateCheckBox = null;
            CheckBox tumblrSyndicateCheckBox = null;
            CheckBox facebookSyndicateCheckBox = null;

            if (e.Owner is User)
            {
                User user = (User)e.Owner;

                if (user.UserInfo.TwitterAuthenticated)
                {
                    twitterSyndicateCheckBox = new CheckBox("photo-share-twitter");
                    twitterSyndicateCheckBox.Caption = "Twitter";
                    twitterSyndicateCheckBox.Icon = "https://g.twimg.com/twitter-bird-16x16.png";
                    twitterSyndicateCheckBox.IsChecked = user.UserInfo.TwitterSyndicate;
                    twitterSyndicateCheckBox.Width.Length = 0;

                    shareCheckBoxArray.Add(twitterSyndicateCheckBox);
                }

                if (user.UserInfo.TumblrAuthenticated)
                {
                    tumblrSyndicateCheckBox = new CheckBox("photo-share-tumblr");
                    tumblrSyndicateCheckBox.Caption = "Tumblr";
                    tumblrSyndicateCheckBox.Icon = "https://platform.tumblr.com/v1/share_4.png";
                    tumblrSyndicateCheckBox.IsChecked = user.UserInfo.TumblrSyndicate;
                    tumblrSyndicateCheckBox.Width.Length = 0;

                    shareCheckBoxArray.Add(tumblrSyndicateCheckBox);
                }

                if (user.UserInfo.FacebookAuthenticated)
                {
                    facebookSyndicateCheckBox = new CheckBox("photo-share-facebook");
                    facebookSyndicateCheckBox.Caption = "Facebook";
                    facebookSyndicateCheckBox.Icon = "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yU/r/fWK1wxX-qQn.png";
                    facebookSyndicateCheckBox.IsChecked = user.UserInfo.FacebookSyndicate;
                    facebookSyndicateCheckBox.Width.Length = 0;

                    shareCheckBoxArray.Add(facebookSyndicateCheckBox);
                }

            }

            if (shareCheckBoxArray.Count > 0)
            {
                template.Parse("S_SHARE", "TRUE");
            }
            if (twitterSyndicateCheckBox != null)
            {
                template.Parse("S_SHARE_TWITTER", twitterSyndicateCheckBox);
            }
            if (tumblrSyndicateCheckBox != null)
            {
                template.Parse("S_SHARE_TUMBLR", tumblrSyndicateCheckBox);
            }
            if (facebookSyndicateCheckBox != null)
            {
                template.Parse("S_SHARE_FACEBOOK", facebookSyndicateCheckBox);
            }

            e.core.AddPostPanel(e.core.Prose.GetString("PHOTO"), template);
        }
        void AccountProfileManage_Show(object sender, EventArgs e)
        {
            SetTemplate("account_profile");

            Musician musician = (Musician)Owner;

            /* */
            TextBox biographyTextBox = new TextBox("biography");
            biographyTextBox.IsFormatted = true;
            biographyTextBox.Lines = 7;

            /* */
            TextBox homepageTextBox = new TextBox("homepage");
            homepageTextBox.MaxLength = 1024;

            /* */
            TextBox nameTextBox = new TextBox("name");
            nameTextBox.IsDisabled = true;
            nameTextBox.MaxLength = 63;

            /* */
            SelectBox genreSelectBox = new SelectBox("genre");

            /* */
            SelectBox musicianTypeSelectBox = new SelectBox("musician-type");

            List<MusicGenre> genres = MusicGenre.GetGenres(core);

            foreach (MusicGenre genre in genres)
            {
                genreSelectBox.Add(new SelectBoxItem(genre.Id.ToString(), genre.Name));
            }

            musicianTypeSelectBox.Add(new SelectBoxItem(((byte)MusicianType.Musician).ToString(), "Musician"));
            musicianTypeSelectBox.Add(new SelectBoxItem(((byte)MusicianType.Duo).ToString(), "Duo"));
            musicianTypeSelectBox.Add(new SelectBoxItem(((byte)MusicianType.Trio).ToString(), "Trio"));
            musicianTypeSelectBox.Add(new SelectBoxItem(((byte)MusicianType.Quartet).ToString(), "Quartet"));
            musicianTypeSelectBox.Add(new SelectBoxItem(((byte)MusicianType.Quintet).ToString(), "Quintet"));
            musicianTypeSelectBox.Add(new SelectBoxItem(((byte)MusicianType.Band).ToString(), "Band"));
            musicianTypeSelectBox.Add(new SelectBoxItem(((byte)MusicianType.Group).ToString(), "Group"));
            musicianTypeSelectBox.Add(new SelectBoxItem(((byte)MusicianType.Orchestra).ToString(), "Orchestra"));
            musicianTypeSelectBox.Add(new SelectBoxItem(((byte)MusicianType.Choir).ToString(), "Choir"));

            biographyTextBox.Value = musician.Biography;
            homepageTextBox.Value = musician.Homepage;
            nameTextBox.Value = musician.TitleName;
            musicianTypeSelectBox.SelectedKey = ((byte)musician.MusicianType).ToString();

            template.Parse("S_BIOGRAPHY", biographyTextBox);
            template.Parse("S_HOMEPAGE", homepageTextBox);
            template.Parse("S_NAME", nameTextBox);
            template.Parse("S_GENRE", genreSelectBox);
            template.Parse("S_MUSICIAN_TYPE", musicianTypeSelectBox);

            Save(AccountProfileManage_Save);
        }
        public SelectBox BuildGroupsSelectBox(string name, Primitive owner)
        {
            SelectBox sb = new SelectBox(name);

            //sb.Add(new SelectBoxItem(string.Format("{0},{1}", ItemType.GetTypeId(typeof(User)), -1), "Everyone"));

            List<PrimitivePermissionGroup> ownerGroups = new List<PrimitivePermissionGroup>();
            int itemGroups = 0;

            Type type = item.GetType();
            if (type.GetMethod(type.Name + "_GetItemGroups", new Type[] { typeof(Core) }) != null)
            {
                ownerGroups.AddRange((List<PrimitivePermissionGroup>)type.InvokeMember(type.Name + "_GetItemGroups", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, new object[] { core }));
                itemGroups = ownerGroups.Count;
            }

            ownerGroups.AddRange(core.GetPrimitivePermissionGroups(owner));

            int i = 0;
            foreach (PrimitivePermissionGroup ppg in ownerGroups)
            {
                if (i == 0 && itemGroups > 0)
                {
                    sb.Add(new SelectBoxItem("-1", "Item groups", false));
                }
                if (i == itemGroups)
                {
                    sb.Add(new SelectBoxItem("-2", "Friendship groups", false));
                }
                if (!string.IsNullOrEmpty(ppg.LanguageKey))
                {
                    sb.Add(new SelectBoxItem(string.Format("{0},{1}", ppg.TypeId, ppg.ItemId), " -- " + core.Prose.GetString(ppg.LanguageKey)));
                }
                else
                {
                    sb.Add(new SelectBoxItem(string.Format("{0},{1}", ppg.TypeId, ppg.ItemId), " -- " + ppg.DisplayName));
                }
                i++;
            }

            return sb;
        }
Beispiel #19
0
        void McpMain_Show(object sender, EventArgs e)
        {
            //AuthoriseRequestSid();
            SetTemplate("mcp_main");

            /* */
            SubmitButton submitButton = new SubmitButton("submit", "Submit");

            /* */
            SelectBox actionsSelectBox = new SelectBox("mode");

            long forumId = core.Functions.RequestLong("f", 0);
            Forum thisForum = null;
            ForumSettings settings = null;

            try
            {
                settings = new ForumSettings(core, Owner);
                if (forumId > 0)
                {
                    thisForum = new Forum(core, settings, forumId);
                }
                else
                {
                    thisForum = new Forum(core, settings);
                }
            }
            catch (InvalidForumSettingsException)
            {
                core.Functions.Generate404();
            }
            catch (InvalidForumException)
            {
                core.Functions.Generate404();
            }

            if (thisForum.Access.Can("LOCK_TOPICS"))
            {
                actionsSelectBox.Add(new SelectBoxItem("lock", "Lock"));
                actionsSelectBox.Add(new SelectBoxItem("unlock", "Unlock"));
            }
            if (thisForum.Access.Can("MOVE_TOPICS"))
            {
                actionsSelectBox.Add(new SelectBoxItem("move", "Move"));
            }
            if (thisForum.Access.Can("DELETE_TOPICS"))
            {
                actionsSelectBox.Add(new SelectBoxItem("delete", "Delete"));
            }

            List<ForumTopic> announcements = thisForum.GetAnnouncements();
            List<ForumTopic> topics = thisForum.GetTopics(core.TopLevelPageNumber, settings.TopicsPerPage);
            List<ForumTopic> allTopics = new List<ForumTopic>();
            allTopics.AddRange(announcements);
            allTopics.AddRange(topics);

            Dictionary<long, TopicPost> topicLastPosts;

            topicLastPosts = TopicPost.GetTopicLastPosts(core, allTopics);

            foreach (ForumTopic topic in allTopics)
            {
                core.LoadUserProfile(topic.PosterId);
            }

            foreach (ForumTopic topic in allTopics)
            {
                VariableCollection topicVariableCollection = template.CreateChild("topic_list");

                CheckBox checkBox = new CheckBox("checkbox[" + topic.Id.ToString() + "]");

                topicVariableCollection.Parse("TITLE", topic.Title);
                topicVariableCollection.Parse("URI", topic.Uri);
                topicVariableCollection.Parse("VIEWS", topic.Views.ToString());
                topicVariableCollection.Parse("REPLIES", topic.Posts.ToString());
                topicVariableCollection.Parse("DATE", core.Tz.DateTimeToString(topic.GetCreatedDate(core.Tz)));
                topicVariableCollection.Parse("USERNAME", core.PrimitiveCache[topic.PosterId].DisplayName);
                topicVariableCollection.Parse("U_POSTER", core.PrimitiveCache[topic.PosterId].Uri);
                topicVariableCollection.Parse("S_CHECK", checkBox);

                if (topicLastPosts.ContainsKey(topic.LastPostId))
                {
                    core.Display.ParseBbcode(topicVariableCollection, "LAST_POST", string.Format("[iurl={0}]{1}[/iurl]\n{2}",
                        topicLastPosts[topic.LastPostId].Uri, Functions.TrimStringToWord(topicLastPosts[topic.LastPostId].Title, 20), core.Tz.DateTimeToString(topicLastPosts[topic.LastPostId].GetCreatedDate(core.Tz))));
                }
                else
                {
                    topicVariableCollection.Parse("LAST_POST", "No posts");
                }

                switch (topic.Status)
                {
                    case TopicStates.Normal:
                        if (topic.IsRead)
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_NORMAL_READ_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_NORMAL_READ_UNLOCKED", "TRUE");
                            }
                        }
                        else
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_NORMAL_UNREAD_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_NORMAL_UNREAD_UNLOCKED", "TRUE");
                            }
                        }
                        break;
                    case TopicStates.Sticky:
                        if (topic.IsRead)
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_STICKY_READ_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_STICKY_READ_UNLOCKED", "TRUE");
                            }
                        }
                        else
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_STICKY_UNREAD_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_STICKY_UNREAD_UNLOCKED", "TRUE");
                            }
                        }

                        break;
                    case TopicStates.Announcement:
                    case TopicStates.Global:
                        if (topic.IsRead)
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_ANNOUNCEMENT_READ_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_ANNOUNCEMENT_READ_UNLOCKED", "TRUE");
                            }
                        }
                        else
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_ANNOUNCEMENT_UNREAD_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_ANNOUNCEMENT_UNREAD_UNLOCKED", "TRUE");
                            }
                        }

                        break;
                }
            }

            template.Parse("TOPICS", allTopics.Count.ToString());
            template.Parse("S_ACTIONS", actionsSelectBox);
            template.Parse("S_SUBMIT", submitButton);
        }
        void AccountContactManage_AddPhone(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_phone_edit");

            /**/
            TextBox phoneNumberTextBox = new TextBox("phone-number");

            /* */
            SelectBox phoneTypeSelectBox = new SelectBox("phone-type");
            phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.Home).ToString(), "Home"));
            phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.Mobile).ToString(), "Mobile"));
            phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.Business).ToString(), "Business"));
            phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.BusinessMobile).ToString(), "BusinessMobile"));
            phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.VoIP).ToString(), "VoIP"));
            phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.Fax).ToString(), "Fax"));
            phoneTypeSelectBox.Add(new SelectBoxItem(((byte)PhoneNumberTypes.Other).ToString(), "Other"));

            switch (e.Mode)
            {
                case "add-phone":
                    break;
                case "edit-phone":
                    long phoneNumberId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0));
                    UserPhoneNumber phoneNumber = null;

                    if (phoneNumberId > 0)
                    {
                        try
                        {
                            phoneNumber = new UserPhoneNumber(core, phoneNumberId);

                            //phoneNumberTextBox.IsDisabled = true;
                            phoneNumberTextBox.Value = phoneNumber.PhoneNumber;

                            if (phoneTypeSelectBox.ContainsKey(((byte)phoneNumber.PhoneType).ToString()))
                            {
                                phoneTypeSelectBox.SelectedKey = ((byte)phoneNumber.PhoneType).ToString();
                            }

                            template.Parse("S_ID", phoneNumber.Id.ToString());
                        }
                        catch (InvalidUserPhoneNumberException)
                        {
                        }
                    }

                    template.Parse("EDIT", "TRUE");
                    break;
            }

            template.Parse("S_PHONE_NUMBER", phoneNumberTextBox);
            template.Parse("S_PHONE_TYPE", phoneTypeSelectBox);
        }
        void AccountForumManage_New(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_forum_edit");

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

            /* Forum Types SelectBox */
            SelectBox forumTypesSelectBox = new SelectBox("type");
            Dictionary<string, string> forumTypes = new Dictionary<string, string>();
            forumTypesSelectBox.Add(new SelectBoxItem("FORUM", "Forum"));
            forumTypesSelectBox.Add(new SelectBoxItem("CAT", "Category"));
            //forumTypes.Add("LINK", "Link");

            /* Forum Types SelectBox */
            SelectBox forumParentSelectBox = new SelectBox("parent");

            /* Title TextBox */
            TextBox titleTextBox = new TextBox("title");
            titleTextBox.MaxLength = 127;

            /* Description TextBox */
            TextBox descriptionTextBox = new TextBox("description");
            descriptionTextBox.IsFormatted = true;
            descriptionTextBox.Lines = 6;

            /* Rules TextBox */
            TextBox rulesTextBox = new TextBox("rules");
            rulesTextBox.IsFormatted = true;
            rulesTextBox.Lines = 6;

            ForumSettings settings = new ForumSettings(core, Owner);
            List<Forum> forums = settings.GetForums();

            forumParentSelectBox.Add(new SelectBoxItem("0", ""));
            foreach (Forum forum in forums)
            {
                string levelString = string.Empty;

                for (int i = 0; i < forum.Level; i++)
                {
                    levelString += "--";
                }

                SelectBoxItem item = new SelectBoxItem(forum.Id.ToString(), levelString + " " + forum.Title);

                if (forum.Id == id && e.Mode == "edit")
                {
                    item.Selectable = false;
                }

                forumParentSelectBox.Add(item);
            }

            switch (e.Mode)
            {
                case "new":
                    forumTypesSelectBox.SelectedKey = "FORUM";

                    template.Parse("S_ID", id.ToString());
                    forumParentSelectBox.SelectedKey = id.ToString();

                    break;
                case "edit":
                    try
                    {
                        Forum forum = new Forum(core, id);

                        string type = "FORUM";

                        if (forum.IsCategory)
                        {
                            type = "CAT";
                        }

                        titleTextBox.Value = forum.Title;
                        forumParentSelectBox.SelectedKey = forum.ParentId.ToString();
                        descriptionTextBox.Value = forum.Description;
                        rulesTextBox.Value = forum.Rules;

                        template.Parse("S_ID", forum.Id.ToString());

                        List<string> disabledItems = new List<string>();
                        forumTypesSelectBox["FORUM"].Selectable = false;
                        forumTypesSelectBox["CAT"].Selectable = false;
                        //forumTypesSelectBox["LINK"].Selectable = false;

                        forumTypesSelectBox.SelectedKey = type;

                        template.Parse("EDIT", "TRUE");
                    }
                    catch (InvalidForumException)
                    {
                        DisplayGenericError();
                    }
                    break;
            }

            /* Parse the form fields */
            template.Parse("S_TITLE", titleTextBox);
            template.Parse("S_DESCRIPTION", descriptionTextBox);
            template.Parse("S_RULES", rulesTextBox);
            template.Parse("S_FORUM_TYPE", forumTypesSelectBox);
            template.Parse("S_FORUM_PARENT", forumParentSelectBox);
        }
Beispiel #22
0
        internal static void ShowRegister(object sender, ShowPageEventArgs e)
        {
            e.Template.SetTemplate("Groups", "creategroup.html");

            if (e.Core.Session.IsLoggedIn == false)
            {
                e.Template.Parse("REDIRECT_URI", "/sign-in/?redirect=/groups/register");
                e.Core.Display.ShowMessage("Not Logged In", "You must be logged in to register a new group.");
                return;
            }

            e.Template.Parse("S_POST", e.Core.Hyperlink.AppendSid("/groups/register/", true));

            string selected = "checked=\"checked\" ";
            long category = 1;
            bool categoryError = false;
            bool typeError = false;
            bool categoryFound = true;
            string slug = e.Core.Http.Form["slug"];
            string title = e.Core.Http.Form["title"];

            try
            {
                category = short.Parse(e.Core.Http["category"]);
            }
            catch
            {
                categoryError = true;
            }

            if (string.IsNullOrEmpty(slug))
            {
                slug = title;
            }

            if (!string.IsNullOrEmpty(title))
            {
                // normalise slug if it has been fiddeled with
                slug = slug.ToLower().Normalize(NormalizationForm.FormD);
                string normalisedSlug = "";

                for (int i = 0; i < slug.Length; i++)
                {
                    if (CharUnicodeInfo.GetUnicodeCategory(slug[i]) != UnicodeCategory.NonSpacingMark)
                    {
                        normalisedSlug += slug[i];
                    }
                }
                slug = Regex.Replace(normalisedSlug, @"([\W]+)", "-");
            }

            SelectBox categoriesSelectBox = new SelectBox("category");

            SelectQuery query = Item.GetSelectQueryStub(e.Core, typeof(Category));
            query.AddSort(SortOrder.Ascending, "category_title");

            DataTable categoriesTable = e.Db.Query(query);
            foreach (DataRow categoryRow in categoriesTable.Rows)
            {
                Category cat = new Category(e.Core, categoryRow);

                categoriesSelectBox.Add(new SelectBoxItem(cat.Id.ToString(), cat.Title));

                if (category == cat.Id)
                {
                    categoryFound = true;
                }
            }

            categoriesSelectBox.SelectedKey = category.ToString();

            if (!categoryFound)
            {
                categoryError = true;
            }

            if (e.Core.Http.Form["submit"] == null)
            {
                prepareNewCaptcha(e.Core);

                e.Template.Parse("S_CATEGORIES", categoriesSelectBox);
                e.Template.Parse("S_OPEN_CHECKED", selected);
            }
            else
            {
                // submit the form
                e.Template.Parse("GROUP_TITLE", (string)e.Core.Http.Form["title"]);
                e.Template.Parse("GROUP_NAME_SLUG", slug);
                e.Template.Parse("GROUP_DESCRIPTION", (string)e.Core.Http.Form["description"]);
                e.Template.Parse("S_CATEGORIES", categoriesSelectBox);

                switch ((string)e.Core.Http.Form["type"])
                {
                    case "open":
                        e.Template.Parse("S_OPEN_CHECKED", selected);
                        break;
                    case "request":
                        e.Template.Parse("S_REQUEST_CHECKED", selected);
                        break;
                    case "closed":
                        e.Template.Parse("S_CLOSED_CHECKED", selected);
                        break;
                    case "private":
                        e.Template.Parse("S_PRIVATE_CHECKED", selected);
                        break;
                    default:
                        typeError = true;
                        break;
                }

                DataTable confirmTable = e.Db.Query(string.Format("SELECT confirm_code FROM confirm WHERE confirm_type = 2 AND session_id = '{0}' LIMIT 1",
                    Mysql.Escape(e.Core.Session.SessionId)));

                if (confirmTable.Rows.Count != 1)
                {
                    e.Template.Parse("ERROR", "Captcha is invalid, please try again.");
                    prepareNewCaptcha(e.Core);
                }
                else if (((string)confirmTable.Rows[0]["confirm_code"]).ToLower() != ((string)e.Core.Http.Form["captcha"]).ToLower())
                {
                    e.Template.Parse("ERROR", "Captcha is invalid, please try again.");
                    prepareNewCaptcha(e.Core);
                }
                else if (!UserGroup.CheckGroupNameValid(slug))
                {
                    e.Template.Parse("ERROR", "Group slug is invalid, you may only use letters, numbers, period, underscores or a dash (a-z, 0-9, '_', '-', '.').");
                    prepareNewCaptcha(e.Core);
                }
                else if (!UserGroup.CheckGroupNameUnique(e.Core, slug))
                {
                    e.Template.Parse("ERROR", "Group slug is already taken, please choose another one.");
                    prepareNewCaptcha(e.Core);
                }
                else if (categoryError)
                {
                    e.Template.Parse("ERROR", "Invalid Category selected, you may have to reload the page.");
                    prepareNewCaptcha(e.Core);
                }
                else if (typeError)
                {
                    e.Template.Parse("ERROR", "Invalid group type selected, you may have to reload the page.");
                    prepareNewCaptcha(e.Core);
                }
                else if ((string)e.Core.Http.Form["agree"] != "true")
                {
                    e.Template.Parse("ERROR", "You must accept the " + e.Core.Settings.SiteTitle + " Terms of Service to create a group.");
                    prepareNewCaptcha(e.Core);
                }
                else
                {
                    UserGroup newGroup = null;
                    try
                    {
                        newGroup = UserGroup.Create(e.Core, e.Core.Http.Form["title"], slug, e.Core.Http.Form["description"], category, e.Core.Http.Form["type"]);
                    }
                    catch (InvalidOperationException)
                    {
                        /*Response.Write("InvalidOperationException<br />");
                        Response.Write(e.Db.QueryList);
                        Response.End();*/
                    }
                    catch (InvalidGroupException)
                    {
                        /*Response.Write("InvalidGroupException<br />");
                        Response.Write(e.Db.QueryList);
                        Response.End();*/
                    }

                    if (newGroup == null)
                    {
                        e.Template.Parse("ERROR", "Bad registration details");
                        prepareNewCaptcha(e.Core);
                    }
                    else
                    {
                        // captcha is a use once thing, destroy all for this session
                        e.Db.UpdateQuery(string.Format("DELETE FROM confirm WHERE confirm_type = 2 AND session_id = '{0}'",
                            Mysql.Escape(e.Core.Session.SessionId)));

                        //Response.Redirect("/", true);
                        e.Template.Parse("REDIRECT_URI", newGroup.Uri);
                        e.Core.Display.ShowMessage("Group Created", "You have have created a new group. You will be redirected to the group home page in a second.");
                        return; /* stop processing the display of this page */
                    }
                }
            }
        }
        void AccountDiscographyManage_Edit(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_discography_album_edit");

            /* */
            TextBox titleTextBox = new TextBox("title");
            titleTextBox.MaxLength = 63;

            /* */
            SelectBox releaseTypeSelectBox = new SelectBox("release-type");
            releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.Demo).ToString(), "Demo"));
            releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.Single).ToString(), "Single"));
            releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.Album).ToString(), "Album"));
            releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.EP).ToString(), "EP"));
            releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.DVD).ToString(), "DVD"));
            releaseTypeSelectBox.Add(new SelectBoxItem(((byte)ReleaseType.Compilation).ToString(), "Compilation"));

            switch (e.Mode)
            {
                case "add":

                    releaseTypeSelectBox.SelectedKey = ((byte)ReleaseType.Demo).ToString();
                    break;
                case "edit":
                    long releaseId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0));

                    Release release = null;

                    try
                    {
                        release = new Release(core, releaseId);

                        titleTextBox.Value = release.Title;
                        releaseTypeSelectBox.SelectedKey = ((byte)release.ReleaseType).ToString();
                    }
                    catch (InvalidReleaseException)
                    {
                        return;
                    }
                    break;
            }

            template.Parse("S_TITLE", titleTextBox);

            SaveMode(AccountDiscographyManage_EditSave);
        }
Beispiel #24
0
        /// <summary>
        /// Default show procedure for account sub module.
        /// </summary>
        /// <param name="sender">Object calling load event</param>
        /// <param name="e">Load EventArgs</param>
        void AccountBlogWrite_Show(object sender, EventArgs e)
        {
            SetTemplate("account_post");

            VariableCollection javaScriptVariableCollection = core.Template.CreateChild("javascript_list");
            javaScriptVariableCollection.Parse("URI", @"/scripts/jquery.sceditor.bbcode.min.js");

            VariableCollection styleSheetVariableCollection = core.Template.CreateChild("style_sheet_list");
            styleSheetVariableCollection.Parse("URI", @"/styles/jquery.sceditor.theme.default.min.css");

            core.Template.Parse("OWNER_STUB", Owner.UriStubAbsolute);

            Blog blog = new Blog(core, (User)Owner);

            /* Title TextBox */
            TextBox titleTextBox = new TextBox("title");
            titleTextBox.MaxLength = 127;

            /* Post TextBox */
            TextBox postTextBox = new TextBox("post");
            postTextBox.IsFormatted = true;
            postTextBox.Lines = 15;

            /* Tags TextBox */
            TagSelectBox tagsTextBox = new TagSelectBox(core, "tags");
            //tagsTextBox.MaxLength = 127;

            CheckBox publishToFeedCheckBox = new CheckBox("publish-feed");
            publishToFeedCheckBox.IsChecked = true;

            long postId = core.Functions.RequestLong("id", 0);
            byte licenseId = (byte)0;
            short categoryId = (short)1;
            DateTime postTime = core.Tz.Now;

            SelectBox postYearsSelectBox = new SelectBox("post-year");
            for (int i = core.Tz.Now.AddYears(-7).Year; i <= core.Tz.Now.Year; i++)
            {
                postYearsSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            postYearsSelectBox.SelectedKey = postTime.Year.ToString();

            SelectBox postMonthsSelectBox = new SelectBox("post-month");
            for (int i = 1; i < 13; i++)
            {
                postMonthsSelectBox.Add(new SelectBoxItem(i.ToString(), core.Functions.IntToMonth(i)));
            }

            postMonthsSelectBox.SelectedKey = postTime.Month.ToString();

            SelectBox postDaysSelectBox = new SelectBox("post-day");
            for (int i = 1; i < 32; i++)
            {
                postDaysSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString()));
            }

            postDaysSelectBox.SelectedKey = postTime.Day.ToString();

            if (postId > 0 && core.Http.Query["mode"] == "edit")
            {
                try
                {
                    BlogEntry be = new BlogEntry(core, postId);

                    titleTextBox.Value = be.Title;
                    postTextBox.Value = be.Body;

                    licenseId = be.License;
                    categoryId = be.Category;

                    postTime = be.GetPublishedDate(tz);

                    List<Tag> tags = Tag.GetTags(core, be);

                    //string tagList = string.Empty;

                    foreach (Tag tag in tags)
                    {
                        /*if (tagList != string.Empty)
                        {
                            tagList += ", ";
                        }
                        tagList += tag.TagText;*/
                        tagsTextBox.AddTag(tag);
                    }

                    //tagsTextBox.Value = tagList;

                    if (be.OwnerId != core.LoggedInMemberId)
                    {
                        DisplayError("You must be the owner of the blog entry to modify it.");
                        return;
                    }
                }
                catch (InvalidBlogEntryException)
                {
                    DisplayError(core.Prose.GetString("Blog", "BLOG_ENTRY_DOES_NOT_EXIST"));
                    return;
                }
            }
            else
            {
                template.Parse("IS_NEW", "TRUE");

                PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", blog.ItemKey);
                HiddenField aclModeField = new HiddenField("aclmode");
                aclModeField.Value = "simple";

                template.Parse("S_PERMISSIONS", permissionSelectBox);
                template.Parse("S_ACLMODE", aclModeField);
            }

            template.Parse("S_POST_YEAR", postYearsSelectBox);
            template.Parse("S_POST_MONTH", postMonthsSelectBox);
            template.Parse("S_POST_DAY", postDaysSelectBox);
            template.Parse("S_POST_HOUR", postTime.Hour.ToString());
            template.Parse("S_POST_MINUTE", postTime.Minute.ToString());

            SelectBox licensesSelectBox = new SelectBox("license");
            DataTable licensesTable = db.Query(ContentLicense.GetSelectQueryStub(core, typeof(ContentLicense)));

            licensesSelectBox.Add(new SelectBoxItem("0", "Default License"));
            foreach (DataRow licenseRow in licensesTable.Rows)
            {
                ContentLicense li = new ContentLicense(core, licenseRow);
                licensesSelectBox.Add(new SelectBoxItem(li.Id.ToString(), li.Title));
            }

            licensesSelectBox.SelectedKey = licenseId.ToString();

            SelectBox categoriesSelectBox = new SelectBox("category");
            SelectQuery query = Category.GetSelectQueryStub(core, typeof(Category));
            query.AddSort(SortOrder.Ascending, "category_title");

            DataTable categoriesTable = db.Query(query);

            foreach (DataRow categoryRow in categoriesTable.Rows)
            {
                Category cat = new Category(core, categoryRow);
                categoriesSelectBox.Add(new SelectBoxItem(cat.Id.ToString(), cat.Title));
            }

            categoriesSelectBox.SelectedKey = categoryId.ToString();

            /* Parse the form fields */
            template.Parse("S_TITLE", titleTextBox);
            template.Parse("S_BLOG_TEXT", postTextBox);
            template.Parse("S_TAGS", tagsTextBox);

            template.Parse("S_BLOG_LICENSE", licensesSelectBox);
            template.Parse("S_BLOG_CATEGORY", categoriesSelectBox);

            template.Parse("S_PUBLISH_FEED", publishToFeedCheckBox);

            template.Parse("S_ID", postId.ToString());

            foreach (Emoticon emoticon in core.Emoticons)
            {
                if (emoticon.Category == "modifier") continue;
                if (emoticon.Category == "people" && emoticon.Code.Length < 3)
                {
                    VariableCollection emoticonVariableCollection = template.CreateChild("emoticon_list");
                    emoticonVariableCollection.Parse("CODE", emoticon.Code);
                    emoticonVariableCollection.Parse("URI", emoticon.File);
                }
                else
                {
                    VariableCollection emoticonVariableCollection = template.CreateChild("emoticon_hidden_list");
                    emoticonVariableCollection.Parse("CODE", emoticon.Code);
                    emoticonVariableCollection.Parse("URI", emoticon.File);
                }
            }

            Save(new EventHandler(AccountBlogWrite_Save));
            if (core.Http.Form["publish"] != null)
            {
                AccountBlogWrite_Save(this, new EventArgs());
            }
        }
        void AccountForumMemberManage_Edit(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_forum_member_edit");

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

            /* Signature TextBox */
            TextBox signatureTextBox = new TextBox("signature");
            signatureTextBox.IsFormatted = true;
            //signatureTextBox.IsDisabled = true;
            signatureTextBox.Lines = 7;

            /* Ranks SelectBox */
            SelectBox ranksSelectBox = new SelectBox("ranks");

            try
            {
                member = new ForumMember(core, Owner, id, UserLoadOptions.All);
            }
            catch (InvalidForumMemberException)
            {
                core.Functions.Generate404();
            }
            catch (InvalidUserException)
            {
                core.Functions.Generate404();
            }

            ranksSelectBox.Add(new SelectBoxItem("0", "None"));

            Dictionary<long, ForumMemberRank> ranks = ForumMemberRank.GetRanks(core, Owner);

            foreach (ForumMemberRank rank in ranks.Values)
            {
                ranksSelectBox.Add(new SelectBoxItem(rank.Id.ToString(), rank.RankTitleText));
            }

            if (ranksSelectBox.ContainsKey(member.ForumRankId.ToString()))
            {
                ranksSelectBox.SelectedKey = member.ForumRankId.ToString();
            }

            signatureTextBox.Value = member.ForumSignature;

            /* Parse the form fields */
            template.Parse("S_USERNAME", member.UserName);
            template.Parse("S_RANK", ranksSelectBox);
            template.Parse("S_SIGNATURE", signatureTextBox);
            template.Parse("S_ID", id.ToString());
        }