Exemplo n.º 1
0
        protected void BeginMusicianPage()
        {
            musicianSlug = core.Http["mn"];

            try
            {
                primitive = new Musician(core, musicianSlug);
            }
            catch (InvalidMusicianException)
            {
                core.Functions.Generate404();
                return;
            }

            // We do not have customised domains for musician
            if (/*string.IsNullOrEmpty(mus.Domain) ||*/ Hyperlink.Domain == core.Http.Domain)
            {
                core.PagePath = core.PagePath.Substring(Musician.Key.Length + 1 + 6);
            }
            if (core.PagePath.Trim(new char[] { '/' }) == "")
            {
                core.PagePath = Musician.Homepage;
            }
            if (core.PagePath.Trim(new char[] { '/' }) == "")
            {
                core.PagePath = "/profile";
            }

            if (loggedInMember != null)
            {
                if (loggedInMember.UserInfo.ShowCustomStyles)
                {
                    template.Parse("USER_STYLE_SHEET", string.Format("music/{0}.css", primitive.Key));
                }
            }
            else
            {
                template.Parse("USER_STYLE_SHEET", string.Format("music/{0}.css", primitive.Key));
            }

            if (!core.PagePath.StartsWith("/account", StringComparison.Ordinal))
            {
                BoxSocial.Internals.Application.LoadApplications(core, AppPrimitives.Musician, core.PagePath, BoxSocial.Internals.Application.GetApplications(core, primitive));

                core.FootHooks += new Core.HookHandler(core_FootHooks);
                HookEventArgs e = new HookEventArgs(core, AppPrimitives.Musician, primitive);
                core.InvokeHeadHooks(e);
                core.InvokePrimitiveHeadHooks(e);
                core.InvokeFootHooks(e);
            }

            PageTitle = primitive.DisplayName;
        }
Exemplo n.º 2
0
        public Tour(Core core, Musician musician, long tourId)
            : base(core)
        {
            this.musician = musician;
            ItemLoad += new ItemLoadHandler(Tour_ItemLoad);

            try
            {
                LoadItem(tourId, new FieldValuePair("musician_id", musician.Id));
            }
            catch (InvalidItemException)
            {
                throw new InvalidTourException();
            }
        }
Exemplo n.º 3
0
        public MusicianMember(Core core, Musician owner, User user)
            : base(core)
        {
            // load the info into a the new object being created
            this.userInfo = user.UserInfo;
            this.userProfile = user.Profile;
            this.userStyle = user.Style;
            this.userId = user.UserId;
            this.userName = user.UserName;
            this.domain = user.UserDomain;
            this.emailAddresses = user.EmailAddresses;

            SelectQuery sQuery = MusicianMember.GetSelectQueryStub(core, typeof(MusicianMember));
            sQuery.AddCondition("user_id", user.Id);
            sQuery.AddCondition("musician_id", owner.Id);

            try
            {
                System.Data.Common.DbDataReader reader = core.Db.ReaderQuery(sQuery);
                if (reader.HasRows)
                {
                    reader.Read();

                    loadItemInfo(typeof(MusicianMember), reader);

                    reader.Close();
                    reader.Dispose();
                }
                else
                {
                    reader.Close();
                    reader.Dispose();

                    throw new InvalidMusicianMemberException();
                }
            }
            catch (InvalidItemException)
            {
                throw new InvalidMusicianMemberException();
            }
        }
Exemplo n.º 4
0
        public static Gig Create(Core core, Musician owner, Tour tour, long time, ushort timezone, string city, string venue, string gigAbstract, bool allAges)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            // TODO: fix this
            Item item = Item.Create(core, typeof(Gig), new FieldValuePair("musician_id", owner.Id),
                new FieldValuePair("tour_id", ((tour != null) ? tour.Id : 0)),
                new FieldValuePair("gig_time_ut", time),
                new FieldValuePair("gig_time_zone", timezone),
                new FieldValuePair("gig_city", city),
                new FieldValuePair("gig_venue", venue),
                new FieldValuePair("gig_abstract", gigAbstract),
                new FieldValuePair("gig_all_ages", allAges));

            Gig gig = (Gig)item;

            if (gig.TourId > 0)
            {
                UpdateQuery uQuery = new UpdateQuery(typeof(Tour));
                uQuery.AddField("tour_gigs", new QueryOperation("tour_gigs", QueryOperations.Addition, "1"));
                uQuery.AddCondition("tour_id", gig.TourId);
            }

            return gig;
        }
Exemplo n.º 5
0
        public Gig(Core core, Musician musician, DataRow gigRow)
            : base(core)
        {
            this.musician = musician;
            ItemLoad += new ItemLoadHandler(Gig_ItemLoad);

            try
            {
                loadItemInfo(gigRow);
            }
            catch (InvalidItemException)
            {
                throw new InvalidGigException();
            }
        }
Exemplo n.º 6
0
        public static List<Tour> GetAll(Core core, Musician owner)
        {
            List<Tour> tours = new List<Tour>();

            SelectQuery query = Tour.GetSelectQueryStub(core, typeof(Tour));
            query.AddCondition("musician_id", owner.Id);

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

            foreach (DataRow dr in tourTable.Rows)
            {
                tours.Add(new Tour(core, dr));
            }

            return tours;
        }
Exemplo n.º 7
0
        public static Tour Create(Core core, Musician owner, string title, short year, string tourAbstract)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            // TODO: fix this
            Item item = Item.Create(core, typeof(Tour), new FieldValuePair("musician_id", owner.Id),
                new FieldValuePair("tour_title", title),
                new FieldValuePair("tour_year", year),
                new FieldValuePair("tour_abstract", tourAbstract));

            return (Tour)item;
        }
Exemplo n.º 8
0
        public Tour(Core core, Musician musician, DataRow tourRow)
            : base(core)
        {
            this.musician = musician;
            ItemLoad += new ItemLoadHandler(Tour_ItemLoad);

            try
            {
                loadItemInfo(tourRow);
            }
            catch (InvalidItemException)
            {
                throw new InvalidTourException();
            }
        }
Exemplo n.º 9
0
        public static Release Create(Core core, Musician musician, ReleaseType releaseType, string title, long coverId)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            string slug = title;
            Navigation.GenerateSlug(title, ref slug);

            slug = Functions.TrimStringToWord(slug);

            // TODO: fix this
            Item item = Item.Create(core, typeof(Release), new FieldValuePair("musician_id", musician.Id),
                new FieldValuePair("release_title", title),
                new FieldValuePair("release_slug", slug),
                new FieldValuePair("release_type", (byte)releaseType),
                new FieldValuePair("release_date_ut", UnixTime.UnixTimeStamp()),
                new FieldValuePair("release_cover_art", coverId));

            return (Release)item;
        }
Exemplo n.º 10
0
        public static MusicianMember Create(Core core, Musician musician, User member)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            InsertQuery iQuery = new InsertQuery(typeof(MusicianMember));
            iQuery.AddField("user_id", member.Id);
            iQuery.AddField("musician_id", musician.Id);
            iQuery.AddField("member_date_ut", UnixTime.UnixTimeStamp());
            iQuery.AddField("member_lead", false);
            iQuery.AddField("member_instruments", 0);
            iQuery.AddField("member_stage_name", string.Empty);
            iQuery.AddField("member_biography", string.Empty);

            core.Db.Query(iQuery);

            MusicianMember newMember = new MusicianMember(core, musician, member);

            return newMember;
        }
Exemplo n.º 11
0
        public MusicianMember(Core core, Musician musician, long userId)
            : base(core)
        {
            this.db = db;

            SelectQuery query = GetSelectQueryStub(core, UserLoadOptions.All);
            query.AddCondition("user_keys.user_id", userId);
            query.AddCondition("musician_members.musician_id", musician.Id);

            DataTable memberTable = db.Query(query);

            if (memberTable.Rows.Count == 1)
            {
                loadItemInfo(typeof(MusicianMember), memberTable.Rows[0]);
                core.LoadUserProfile(userId);
                loadUserFromUser(core.PrimitiveCache[userId]);
            }
            else
            {
                throw new InvalidUserException();
            }
        }
Exemplo n.º 12
0
        public MusicianMember(Core core, Musician owner, string username, UserLoadOptions loadOptions)
            : base(core)
        {
            SelectQuery query = GetSelectQueryStub(core, UserLoadOptions.All);
            query.AddCondition("user_keys.username", username);
            query.AddCondition("musician_id", owner.Id);

            DataTable memberTable = db.Query(query);

            if (memberTable.Rows.Count == 1)
            {
                loadItemInfo(typeof(User), memberTable.Rows[0]);
                loadItemInfo(typeof(UserInfo), memberTable.Rows[0]);
                loadItemInfo(typeof(UserProfile), memberTable.Rows[0]);
                loadItemInfo(typeof(MusicianMember), memberTable.Rows[0]);
            }
            else
            {
                throw new InvalidUserException();
            }
        }
Exemplo n.º 13
0
 public static string Uri(Core core, Musician.Musician musician)
 {
     return core.Hyperlink.AppendSid(string.Format("{0}comments",
         musician.UriStub));
 }
Exemplo n.º 14
0
        public static Musician Create(Core core, string title, string slug)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            Mysql db = core.Db;
            SessionState session = core.Session;

            if (core.Session.LoggedInMember == null)
            {
                return null;
            }

            if (!CheckMusicianNameUnique(core, slug))
            {
                return null;
            }

            db.BeginTransaction();
            InsertQuery iQuery = new InsertQuery(Musician.GetTable(typeof(Musician)));
            iQuery.AddField("musician_name", title);
            iQuery.AddField("musician_slug", slug);
            iQuery.AddField("musician_name_first", title.ToLower()[0]);
            iQuery.AddField("musician_reg_ip", session.IPAddress.ToString());
            iQuery.AddField("musician_reg_date_ut", UnixTime.UnixTimeStamp());

            long musicianId = db.Query(iQuery);

            Musician newMusician = new Musician(core, musicianId);

            MusicianMember member = MusicianMember.Create(core, newMusician, session.LoggedInMember);

            try
            {
                ApplicationEntry musicianAe = new ApplicationEntry(core, "Musician");
                musicianAe.Install(core, newMusician);
            }
            catch
            {
            }

            try
            {
                ApplicationEntry galleryAe = new ApplicationEntry(core, "Gallery");
                galleryAe.Install(core, newMusician);
            }
            catch
            {
            }

            try
            {
                ApplicationEntry guestbookAe = new ApplicationEntry(core, "GuestBook");
                guestbookAe.Install(core, newMusician);
            }
            catch
            {
            }

            Access.CreateGrantForPrimitive(core, newMusician, User.GetEveryoneGroupKey(core), "VIEW");
            Access.CreateGrantForPrimitive(core, newMusician, User.GetRegisteredUsersGroupKey(core), "COMMENT");
            Access.CreateGrantForPrimitive(core, newMusician, User.GetRegisteredUsersGroupKey(core), "COMMENT_GIGS");

            return newMusician;
        }
Exemplo n.º 15
0
        public static List<Gig> GetAll(Core core, Musician owner)
        {
            List<Gig> gigs = new List<Gig>();

            SelectQuery query = Gig.GetSelectQueryStub(core, typeof(Gig));
            query.AddCondition("musician_id", owner.Id);

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

            foreach (DataRow dr in gigTable.Rows)
            {
                gigs.Add(new Gig(core, dr));
            }

            return gigs;
        }
Exemplo n.º 16
0
        public Gig(Core core, Musician musician, long gigId)
            : base(core)
        {
            this.musician = musician;
            ItemLoad += new ItemLoadHandler(Gig_ItemLoad);

            try
            {
                LoadItem(gigId, new FieldValuePair("musician_id", musician.Id));
            }
            catch (InvalidItemException)
            {
                throw new InvalidGigException();
            }
        }
Exemplo n.º 17
0
        public static Song Create(Core core, Musician owner, string title, string lyrics, byte licenseId)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            if (owner.IsMusicianMember(core.Session.LoggedInMember.ItemKey))
            {
                Item item = Item.Create(core, typeof(Song), new FieldValuePair("musician_id", owner.Id),
                    new FieldValuePair("song_title", title),
                    new FieldValuePair("song_lyrics", lyrics),
                    new FieldValuePair("song_license", licenseId));

                return (Song)item;
            }
            else
            {
                throw new UnauthorisedToCreateItemException();
            }
        }