Exemplo n.º 1
0
        public static void Show(object sender, ShowPageEventArgs e)
        {
            e.Template.SetTemplate("Groups", "groups_default");

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

            List<Category> categories = Category.GetAll(e.Core);

            e.Template.Parse("CATEGORIES", categories.Count.ToString());

            foreach (Category category in categories)
            {
                if (category.Groups > 0)
                {
                    VariableCollection categoriesVariableCollection = e.Template.CreateChild("category_list");

                    categoriesVariableCollection.Parse("TITLE", category.Title);
                    categoriesVariableCollection.Parse("GROUPS", category.Groups.ToString());
                    categoriesVariableCollection.Parse("U_GROUP_CATEGORY", UserGroup.BuildCategoryUri(e.Core, category));

                    List<UserGroup> groups = UserGroup.GetUserGroups(e.Core, category, 1, 3);

                    foreach (UserGroup group in groups)
                    {
                        VariableCollection groupsVariableCollection = categoriesVariableCollection.CreateChild("group_list");

                        groupsVariableCollection.Parse("GROUP_DISPLAY_NAME", group.DisplayName);
                        groupsVariableCollection.Parse("U_PROFILE", group.Uri);
                        groupsVariableCollection.Parse("ICON", group.Icon);
                        groupsVariableCollection.Parse("TILE", group.Tile);
                        groupsVariableCollection.Parse("MOBILE_COVER", group.MobileCoverPhoto);

                        groupsVariableCollection.Parse("ID", group.Id);
                        groupsVariableCollection.Parse("TYPE", group.TypeId);
                        e.Core.Display.ParseBbcode(groupsVariableCollection, "DESCRIPTION", group.GroupInfo.Description);
                        groupsVariableCollection.Parse("MEMBERS", e.Core.Functions.LargeIntegerToString(group.Members));

                        if (e.Core.Session.IsLoggedIn && !group.IsGroupMember(e.Core.LoggedInMemberItemKey))
                        {
                            groupsVariableCollection.Parse("U_JOIN", group.JoinUri);
                        }
                    }
                }
            }

            List<string[]> breadCrumbParts = new List<string[]>();
            breadCrumbParts.Add(new string[] { "groups", e.Core.Prose.GetString("Groups", "GROUPS") });

            e.Page.ParseCoreBreadCrumbs(breadCrumbParts);
        }
Exemplo n.º 2
0
 public static void ShowChart(object sender, ShowPageEventArgs e)
 {
     e.Template.SetTemplate("Musician", "chart_default");
 }
Exemplo n.º 3
0
        public static void Show(object sender, ShowPageEventArgs e)
        {
            e.Template.SetTemplate("Musician", "music_default");

            e.Template.Parse("U_REGISTER_MUSICIAN", e.Core.Hyperlink.AppendSid("/music/register"));
        }
Exemplo n.º 4
0
        internal static void ShowRegister(object sender, ShowPageEventArgs e)
        {
            e.Template.SetTemplate("createmuiscian.html");

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

            string slug = e.Core.Http.Form["slug"];
            string title = e.Core.Http.Form["title"];

            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 = string.Empty;

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

            if (e.Core.Http.Form["submit"] == null)
            {
                prepareNewCaptcha(e.Core);
            }
            else
            {
                // submit the form
                e.Template.Parse("MUSICIAN_TITLE", e.Core.Http.Form["title"]);
                e.Template.Parse("MUSICIAN_NAME_SLUG", slug);

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

                if (confirmTable.Rows.Count != 1)
                {
                    e.Template.Parse("ERROR", "Captcha error, please try again.");
                    prepareNewCaptcha(e.Core);
                }
                else if (((string)confirmTable.Rows[0]["confirm_code"]).ToLower() != e.Core.Http.Form["captcha"].ToLower())
                {
                    e.Template.Parse("ERROR", "Captcha is invalid, please try again.");
                    prepareNewCaptcha(e.Core);
                }
                else if (!Musician.CheckMusicianNameValid(slug))
                {
                    e.Template.Parse("ERROR", "Musician slug is invalid, you may only use letters, numbers, period, underscores or a dash (a-z, 0-9, '_', '-', '.').");
                    prepareNewCaptcha(e.Core);
                }
                else if (!Musician.CheckMusicianNameUnique(e.Core, slug))
                {
                    e.Template.Parse("ERROR", "Musician slug is already taken, please choose another one.");
                    prepareNewCaptcha(e.Core);
                }
                else if (e.Core.Http.Form["agree"] != "true")
                {
                    e.Template.Parse("ERROR", "You must accept the " + e.Core.Settings.SiteTitle + " Terms of Service to create register a musician.");
                    prepareNewCaptcha(e.Core);
                }
                else
                {
                    Musician newMusician = Musician.Create(e.Core, e.Core.Http.Form["title"], slug);

                    if (newMusician == 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 = 3 AND session_id = '{0}'",
                            Mysql.Escape(e.Core.Session.SessionId)));

                        //Response.Redirect("/", true);
                        e.Template.Parse("REDIRECT_URI", newMusician.Uri);
                        e.Core.Display.ShowMessage("Musician Registered", "You have have registered a new musician. You will be redirected to the musician home page in a second.");
                        return; /* stop processing the display of this page */
                    }
                }
            }
        }
Exemplo n.º 5
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 */
                    }
                }
            }
        }
Exemplo n.º 6
0
        public static void Show(object sender, ShowPageEventArgs e)
        {
            e.Template.SetTemplate("Musician", "music_directory");

            e.Template.Parse("U_MUSIC_ARTISTS", e.Core.Hyperlink.AppendSid("/music/directory/all"));
            e.Template.Parse("U_MUSIC_GENRES", e.Core.Hyperlink.AppendSid("/music/directory/genres"));

            e.Template.Parse("U_FILTER_ALL", e.Core.Hyperlink.AppendSid("/music/directory/all"));
            e.Template.Parse("U_FILTER_BEGINS_A", GetDirectoryUri(e.Core, "a"));
            e.Template.Parse("U_FILTER_BEGINS_B", GetDirectoryUri(e.Core, "b"));
            e.Template.Parse("U_FILTER_BEGINS_C", GetDirectoryUri(e.Core, "c"));
            e.Template.Parse("U_FILTER_BEGINS_D", GetDirectoryUri(e.Core, "d"));
            e.Template.Parse("U_FILTER_BEGINS_E", GetDirectoryUri(e.Core, "e"));
            e.Template.Parse("U_FILTER_BEGINS_F", GetDirectoryUri(e.Core, "f"));
            e.Template.Parse("U_FILTER_BEGINS_G", GetDirectoryUri(e.Core, "g"));
            e.Template.Parse("U_FILTER_BEGINS_H", GetDirectoryUri(e.Core, "h"));
            e.Template.Parse("U_FILTER_BEGINS_I", GetDirectoryUri(e.Core, "i"));
            e.Template.Parse("U_FILTER_BEGINS_J", GetDirectoryUri(e.Core, "j"));
            e.Template.Parse("U_FILTER_BEGINS_K", GetDirectoryUri(e.Core, "k"));
            e.Template.Parse("U_FILTER_BEGINS_L", GetDirectoryUri(e.Core, "l"));
            e.Template.Parse("U_FILTER_BEGINS_M", GetDirectoryUri(e.Core, "m"));
            e.Template.Parse("U_FILTER_BEGINS_N", GetDirectoryUri(e.Core, "n"));
            e.Template.Parse("U_FILTER_BEGINS_O", GetDirectoryUri(e.Core, "o"));
            e.Template.Parse("U_FILTER_BEGINS_P", GetDirectoryUri(e.Core, "p"));
            e.Template.Parse("U_FILTER_BEGINS_Q", GetDirectoryUri(e.Core, "q"));
            e.Template.Parse("U_FILTER_BEGINS_R", GetDirectoryUri(e.Core, "r"));
            e.Template.Parse("U_FILTER_BEGINS_S", GetDirectoryUri(e.Core, "s"));
            e.Template.Parse("U_FILTER_BEGINS_T", GetDirectoryUri(e.Core, "t"));
            e.Template.Parse("U_FILTER_BEGINS_U", GetDirectoryUri(e.Core, "u"));
            e.Template.Parse("U_FILTER_BEGINS_V", GetDirectoryUri(e.Core, "v"));
            e.Template.Parse("U_FILTER_BEGINS_W", GetDirectoryUri(e.Core, "w"));
            e.Template.Parse("U_FILTER_BEGINS_X", GetDirectoryUri(e.Core, "x"));
            e.Template.Parse("U_FILTER_BEGINS_Y", GetDirectoryUri(e.Core, "y"));
            e.Template.Parse("U_FILTER_BEGINS_Z", GetDirectoryUri(e.Core, "z"));

            List<Musician> musicians = Musician.GetMusicians(e.Core, e.Core.Functions.GetFilter(), e.Page.TopLevelPageNumber);

            // TODO: cache
            long musicianCount = musicians.Count; // e.Db.LastQueryRows;

            Dictionary<long, MusicGenre> musicianGenres = MusicGenre.GetGenres(e.Core, musicians);

            foreach (Musician musician in musicians)
            {
                VariableCollection musicianVariableCollection = e.Template.CreateChild("musicians_list");

                musicianVariableCollection.Parse("U_MUSICIAN", musician.Uri);
                musicianVariableCollection.Parse("DISPLAY_NAME", musician.DisplayName);
                musicianVariableCollection.Parse("I_TILE", musician.Tile);
                musicianVariableCollection.Parse("I_ICON", musician.Icon);

                if (musician.GenreRaw > 0 && musicianGenres.ContainsKey(musician.GenreRaw))
                {
                    musicianVariableCollection.Parse("GENRE", musicianGenres[musician.GenreRaw].Name);
                }

                if (musician.SubGenreRaw > 0 && musicianGenres.ContainsKey(musician.SubGenreRaw))
                {
                    musicianVariableCollection.Parse("SUB_GENRE", musicianGenres[musician.SubGenreRaw].Name);
                }
            }

            e.Core.Display.ParsePagination(GetDirectoryUri(e.Core, e.Core.Functions.GetFilter()), e.Page.TopLevelPageNumber, (int)(Math.Ceiling(musicianCount / 10.0)));
        }
Exemplo n.º 7
0
        public static void ShowGenres(object sender, ShowPageEventArgs e)
        {
            e.Template.SetTemplate("Musician", "music_directory_genres");

            List<MusicGenre> genres = MusicGenre.GetGenres(e.Core);

            for (int i = 0; i < genres.Count; i++)
            {
                MusicGenre genre = genres[i];
                if (genre.ParentId == 0)
                {
                    VariableCollection genreVariableCollection = e.Template.CreateChild("genre_list");

                    genreVariableCollection.Parse("U_GENRE", genre.Uri);
                    genreVariableCollection.Parse("DISPLAY_NAME", genre.Name);
                    genreVariableCollection.Parse("MUSICIANS", e.Core.Functions.LargeIntegerToString(genre.Musicians));

                    for (int j = i; j < genres.Count; j++)
                    {
                        MusicGenre subGenre = genres[j];
                        if (subGenre.ParentId == genre.Id)
                        {
                            VariableCollection subGenreVariableCollection = genreVariableCollection.CreateChild("subgenre_list");

                            subGenreVariableCollection.Parse("U_SUBGENRE", subGenre.Uri);
                            subGenreVariableCollection.Parse("DISPLAY_NAME", subGenre.Name);
                            subGenreVariableCollection.Parse("MUSICIANS", e.Core.Functions.LargeIntegerToString(subGenre.Musicians));
                        }
                        else if (subGenre.ParentId < genre.Id)
                        {
                            continue;
                        }
                        else
                        {
                            // gone past the end, start the next genre
                            break;
                        }
                    }
                }
                else
                {
                    break;
                }
            }
        }
Exemplo n.º 8
0
        public static void ShowGenre(object sender, ShowPageEventArgs e)
        {
            e.Template.SetTemplate("Musician", "music_directory_genres");

            string genre = e.Core.PagePathParts[1].Value;
            MusicGenre genreObject = null;

            try
            {
                genreObject = new MusicGenre(e.Core, genre);
            }
            catch (InvalidMusicGenreException)
            {
                e.Core.Functions.Generate404();
                return;
            }

            VariableCollection genreVariableCollection = e.Template.CreateChild("genre_list");

            genreVariableCollection.Parse("U_GENRE", genreObject.Uri);
            genreVariableCollection.Parse("DISPLAY_NAME", genreObject.Name);
            genreVariableCollection.Parse("MUSICIANS", e.Core.Functions.LargeIntegerToString(genreObject.Musicians));

            if (genreObject.ParentId == 0)
            {
                List<MusicGenre> subGenres = genreObject.GetSubGenres();

                foreach (MusicGenre subGenre in subGenres)
                {
                    VariableCollection subGenreVariableCollection = genreVariableCollection.CreateChild("subgenre_list");

                    subGenreVariableCollection.Parse("U_SUBGENRE", subGenre.Uri);
                    subGenreVariableCollection.Parse("DISPLAY_NAME", subGenre.Name);
                    subGenreVariableCollection.Parse("MUSICIANS", e.Core.Functions.LargeIntegerToString(subGenre.Musicians));
                }
            }

            List<Musician> musicians = genreObject.GetMusicians(e.Core.Functions.GetFilter(), e.Page.TopLevelPageNumber);

            // TODO: cache
            long musicianCount = musicians.Count; // e.Db.LastQueryRows;

            Dictionary<long, MusicGenre> musicianGenres = MusicGenre.GetGenres(e.Core, musicians);

            foreach (Musician musician in musicians)
            {
                VariableCollection musicianVariableCollection = e.Template.CreateChild("musicians_list");

                musicianVariableCollection.Parse("U_MUSICIAN", musician.Uri);
                musicianVariableCollection.Parse("DISPLAY_NAME", musician.DisplayName);
                musicianVariableCollection.Parse("I_TILE", musician.Tile);
                musicianVariableCollection.Parse("I_ICON", musician.Icon);

                if (musician.GenreRaw > 0 && musicianGenres.ContainsKey(musician.GenreRaw))
                {
                    musicianVariableCollection.Parse("GENRE", musicianGenres[musician.GenreRaw].Name);
                }

                if (musician.SubGenreRaw > 0 && musicianGenres.ContainsKey(musician.SubGenreRaw))
                {
                    musicianVariableCollection.Parse("SUB_GENRE", musicianGenres[musician.SubGenreRaw].Name);
                }
            }

            e.Template.Parse("ARTISTS", musicianCount.ToString());

            e.Core.Display.ParsePagination(GetDirectoryUri(e.Core, e.Core.Functions.GetFilter(), genreObject.Slug), e.Page.TopLevelPageNumber, (int)(Math.Ceiling(musicianCount / 10.0)));
        }
Exemplo n.º 9
0
        public static void ShowCategory(object sender, ShowPageEventArgs e)
        {
            e.Template.SetTemplate("Groups", "groups_default");

            string categoryPath = e.Core.PagePathParts[1].Value;

            Category category = null;

            try
            {
                category = new Category(e.Core, categoryPath);
            }
            catch (InvalidCategoryException)
            {
                return;
            }

            e.Template.Parse("CATEGORY_TITLE", category.Title);
            e.Template.Parse("U_CREATE_GROUP_C", e.Core.Hyperlink.AppendSid("/groups/register?category=" + category.Id.ToString()));
            e.Template.Parse("U_CREATE_GROUP", e.Core.Hyperlink.AppendSid("/groups/register?category=" + category.Id.ToString()));

            List<UserGroup> groups = UserGroup.GetUserGroups(e.Core, category, e.Page.TopLevelPageNumber);

            VariableCollection categoriesVariableCollection = e.Template.CreateChild("category_list");

            e.Template.Parse("GROUPS", groups.Count.ToString());

            foreach (UserGroup group in groups)
            {
                VariableCollection groupsVariableCollection = categoriesVariableCollection.CreateChild("group_list");

                groupsVariableCollection.Parse("GROUP_DISPLAY_NAME", group.DisplayName);
                groupsVariableCollection.Parse("U_PROFILE", group.Uri);
                groupsVariableCollection.Parse("ICON", group.Icon);
                groupsVariableCollection.Parse("TILE", group.Tile);
                groupsVariableCollection.Parse("MOBILE_COVER", group.MobileCoverPhoto);

                groupsVariableCollection.Parse("ID", group.Id);
                groupsVariableCollection.Parse("TYPE", group.TypeId);
                e.Core.Display.ParseBbcode(groupsVariableCollection, "DESCRIPTION", group.GroupInfo.Description);
                groupsVariableCollection.Parse("MEMBERS", e.Core.Functions.LargeIntegerToString(group.Members));

                if (e.Core.Session.IsLoggedIn && !group.IsGroupMember(e.Core.LoggedInMemberItemKey))
                {
                    groupsVariableCollection.Parse("U_JOIN", group.JoinUri);
                }
            }

            e.Core.Display.ParsePagination(UserGroup.BuildCategoryUri(e.Core, category), UserGroup.GROUPS_PER_PAGE, category.Groups);

            List<string[]> breadCrumbParts = new List<string[]>();
            breadCrumbParts.Add(new string[] { "groups", e.Core.Prose.GetString("GROUPS") });
            breadCrumbParts.Add(new string[] { category.Path, category.Title });

            e.Page.ParseCoreBreadCrumbs(breadCrumbParts);
        }
Exemplo n.º 10
0
        public static void Show(object sender, ShowPageEventArgs e)
        {
            e.Template.SetTemplate("Groups", "viewsubgroup");

            SubUserGroup subgroup;

            try
            {
                subgroup = new SubUserGroup(e.Core, e.Core.PagePathParts[1].Value);
            }
            catch (InvalidSubGroupException)
            {
                e.Core.Functions.Generate404();
                return;
            }

            e.Template.Parse("U_FILTER_ALL", subgroup.Uri);
            e.Template.Parse("U_FILTER_BEGINS_A", subgroup.GetUri("a"));
            e.Template.Parse("U_FILTER_BEGINS_B", subgroup.GetUri("b"));
            e.Template.Parse("U_FILTER_BEGINS_C", subgroup.GetUri("c"));
            e.Template.Parse("U_FILTER_BEGINS_D", subgroup.GetUri("d"));
            e.Template.Parse("U_FILTER_BEGINS_E", subgroup.GetUri("e"));
            e.Template.Parse("U_FILTER_BEGINS_F", subgroup.GetUri("f"));
            e.Template.Parse("U_FILTER_BEGINS_G", subgroup.GetUri("g"));
            e.Template.Parse("U_FILTER_BEGINS_H", subgroup.GetUri("h"));
            e.Template.Parse("U_FILTER_BEGINS_I", subgroup.GetUri("i"));
            e.Template.Parse("U_FILTER_BEGINS_J", subgroup.GetUri("j"));
            e.Template.Parse("U_FILTER_BEGINS_K", subgroup.GetUri("k"));
            e.Template.Parse("U_FILTER_BEGINS_L", subgroup.GetUri("l"));
            e.Template.Parse("U_FILTER_BEGINS_M", subgroup.GetUri("m"));
            e.Template.Parse("U_FILTER_BEGINS_N", subgroup.GetUri("n"));
            e.Template.Parse("U_FILTER_BEGINS_O", subgroup.GetUri("o"));
            e.Template.Parse("U_FILTER_BEGINS_P", subgroup.GetUri("p"));
            e.Template.Parse("U_FILTER_BEGINS_Q", subgroup.GetUri("q"));
            e.Template.Parse("U_FILTER_BEGINS_R", subgroup.GetUri("r"));
            e.Template.Parse("U_FILTER_BEGINS_S", subgroup.GetUri("s"));
            e.Template.Parse("U_FILTER_BEGINS_T", subgroup.GetUri("t"));
            e.Template.Parse("U_FILTER_BEGINS_U", subgroup.GetUri("u"));
            e.Template.Parse("U_FILTER_BEGINS_V", subgroup.GetUri("v"));
            e.Template.Parse("U_FILTER_BEGINS_W", subgroup.GetUri("w"));
            e.Template.Parse("U_FILTER_BEGINS_X", subgroup.GetUri("x"));
            e.Template.Parse("U_FILTER_BEGINS_Y", subgroup.GetUri("y"));
            e.Template.Parse("U_FILTER_BEGINS_Z", subgroup.GetUri("z"));

            List<SubGroupMember> awaitingApproval = subgroup.GetMembersWaitingApproval();

            foreach (SubGroupMember member in awaitingApproval)
            {
                VariableCollection approvalVariableCollection = e.Core.Template.CreateChild("approval_list");

                approvalVariableCollection.Parse("U_MEMBER", member.Uri);
                approvalVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                approvalVariableCollection.Parse("LOCATION", member.Profile.Country);
                approvalVariableCollection.Parse("JOINED", e.Core.Tz.DateTimeToDateString(member.GetJoinedDate(e.Core.Tz)));
            }

            if (awaitingApproval.Count > 0)
            {
                e.Core.Template.Parse("IS_WAITING_APPROVAL", "TRUE");
            }

            List<SubGroupMember> leaders = subgroup.GetLeaders();

            foreach (SubGroupMember member in leaders)
            {
                VariableCollection leaderVariableCollection = e.Core.Template.CreateChild("leader_list");

                leaderVariableCollection.Parse("U_MEMBER", member.Uri);
                leaderVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                leaderVariableCollection.Parse("LOCATION", member.Profile.Country);
                leaderVariableCollection.Parse("JOINED", e.Core.Tz.DateTimeToDateString(member.GetJoinedDate(e.Core.Tz)));
            }

            List<SubGroupMember> members = subgroup.GetMembers(e.Page.TopLevelPageNumber, 20, e.Core.Functions.GetFilter());
            // TODO, cache
            long memberCount = members.Count; // e.Db.LastQueryRows;

            foreach (SubGroupMember member in members)
            {
                VariableCollection memberVariableCollection = e.Core.Template.CreateChild("member_list");

                memberVariableCollection.Parse("U_MEMBER", member.Uri);
                memberVariableCollection.Parse("DISPLAY_NAME", member.DisplayName);
                memberVariableCollection.Parse("LOCATION", member.Profile.Country);
                memberVariableCollection.Parse("JOINED", e.Core.Tz.DateTimeToDateString(member.GetJoinedDate(e.Core.Tz)));

                /*if (string.IsNullOrEmpty(member.UserThumbnail))
                {
                    memberVariableCollection.Parse("I_DISPLAY_PIC", string.Empty);
                }
                else
                {
                    Image displayPic = new Image("display-pic[" + member.Id.ToString() + "]", member.UserThumbnail);
                    memberVariableCollection.Parse("I_DISPLAY_PIC", displayPic);
                }*/
            }

            if (e.Core.Session.IsLoggedIn)
            {
                if (subgroup.IsSubGroupMember(e.Core.Session.LoggedInMember.ItemKey))
                {
                    if (!subgroup.IsSubGroupLeader(e.Core.Session.LoggedInMember))
                    {
                        e.Template.Parse("U_LEAVE", subgroup.LeaveUri);
                    }
                }
                else
                {
                    if (subgroup.SubGroupType == "OPEN" || subgroup.SubGroupType == "REQUEST")
                    {
                        e.Template.Parse("U_JOIN", subgroup.JoinUri);
                    }
                }
            }

            e.Core.Display.ParsePagination(subgroup.GetUri(e.Core.Functions.GetFilter()), e.Page.TopLevelPageNumber, (int)(Math.Ceiling(memberCount / 20.0)));
        }