Esempio n. 1
0
        public List<Page> GetPages(bool draft, bool all)
        {
            List<Page> pages = new List<Page>();

            SelectQuery query = Page.GetSelectQueryStub(core, typeof(Page));
            query.AddCondition("page_item_id", owner.Id);
            query.AddCondition("page_item_type_id", owner.TypeId);
            if (!all)
            {
                query.AddCondition("page_list_only", false);
            }
            if (draft)
            {
                query.AddCondition("page_status", "DRAFT");
            }
            else
            {
                query.AddCondition("page_status", "PUBLISH");
            }
            query.AddSort(SortOrder.Ascending, "page_order");

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

            while(pagesReader.Read())
            {
                pages.Add(new Page(core, owner, pagesReader));
            }

            pagesReader.Close();
            pagesReader.Dispose();

            return pages;
        }
        void AccountNavigationTabs_Add(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_navigation_tab_add");

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

            Dictionary<string, string> pages = new Dictionary<string, string>();
            List<string> disabledItems = new List<string>();

            foreach (Page page in pagesList)
            {
                pages.Add(page.Id.ToString(), page.FullPath);
            }

            ParseSelectBox("S_PAGE_LIST", "page-id", pages, "");
        }
Esempio n. 3
0
        public static void Show(object sender, ShowPPageEventArgs e)
        {
            e.Template.SetTemplate("Pages", "viewlist");

            try
            {
                List list = new List(e.Core, (User)e.Page.Owner, e.Slug);
                Page page = new Page(e.Core, e.Page.Owner, "lists/" + e.Slug);

                if (!list.Access.Can("VIEW"))
                {
                    e.Core.Functions.Generate403();
                    return;
                }

                e.Core.Display.ParsePageList(e.Page.Owner, true, page);

                e.Template.Parse("PAGE_TITLE", list.Title);

                e.Template.Parse("LIST_TITLE", list.title);
                e.Template.Parse("LIST_ID", list.ListId.ToString());
                e.Template.Parse("LIST_LIST", "TRUE");

                if (!string.IsNullOrEmpty(list.Abstract))
                {
                    e.Core.Display.ParseBbcode("LIST_ABSTRACT", list.Abstract);
                }
                else
                {
                    e.Template.Parse("LIST_ABSTRACT", "FALSE");
                }

                List<ListItem> listItems = list.GetListItems();

                if (listItems.Count > 0)
                {
                    e.Template.Parse("NOT_EMPTY", "TRUE");
                }

                foreach (ListItem listItem in listItems)
                {
                    VariableCollection listVariableCollection = e.Template.CreateChild("list_list");

                    listVariableCollection.Parse("TITLE", listItem.Text);
                    listVariableCollection.Parse("URI", "FALSE");

                    if (list.Owner.Id == e.Core.LoggedInMemberId)
                    {
                        listVariableCollection.Parse("U_DELETE", e.Core.Hyperlink.BuildRemoveFromListUri(listItem.ListItemId));
                    }
                }

                List<string[]> breadCrumbParts = new List<string[]>();
                breadCrumbParts.Add(new string[] { "lists", "Lists" });
                breadCrumbParts.Add(new string[] { list.Path, list.Title });

                page.Owner.ParseBreadCrumbs(breadCrumbParts);
            }
            catch (InvalidListException)
            {
                e.Core.Functions.Generate404();
            }
            catch (PageNotFoundException)
            {
                e.Core.Functions.Generate404();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// This may seem confusing, but List<> is a type that the compiler can distinguish from List
        /// </summary>
        /// <param name="db"></param>
        /// <param name="member"></param>
        /// <returns></returns>
        public static List<List> GetLists(Core core, User owner)
        {
            List<List> lists = new List<List>();

            SelectQuery query = Item.GetSelectQueryStub(core, typeof(List));
            query.AddCondition("user_id", owner.Id);

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

            foreach (DataRow dr in listsTable.Rows)
            {
                lists.Add(new List(core, owner, dr));
            }

            return lists;
        }
Esempio n. 5
0
        public static List Create(Core core, string title, ref string slug, string listAbstract, short listType)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            Navigation.GenerateSlug(title, ref slug);

            if (!IsValidListType(core, listType))
            {
                throw new ListTypeNotValidException();
            }

            try
            {
                Page listPage;
                try
                {
                    listPage = new Page(core, core.Session.LoggedInMember, "lists");
                }
                catch (PageNotFoundException)
                {
                    string listsSlug = "lists";
                    try
                    {
                        listPage = Page.Create(core, core.Session.LoggedInMember, "Lists", ref listsSlug, 0, "", PageStatus.PageList, 0, Classifications.None);
                    }
                    catch (PageSlugNotUniqueException)
                    {
                        throw new Exception("Cannot create lists slug.");
                    }
                }
                Page page = Page.Create(core, core.Session.LoggedInMember, title, ref slug, listPage.Id, "", PageStatus.PageList, 0, Classifications.None);

                // Create list

                InsertQuery iQuery = new InsertQuery(GetTable(typeof(List)));
                iQuery.AddField("user_id", core.LoggedInMemberId);
                iQuery.AddField("list_title", title);
                iQuery.AddField("list_path", slug);
                iQuery.AddField("list_type", listType);
                iQuery.AddField("list_abstract", listAbstract);

                long listId = core.Db.Query(iQuery);

                List list = new List(core, core.Session.LoggedInMember, listId);

                /* LOAD THE DEFAULT ITEM PERMISSIONS */
                list.Access.CreateAllGrantsForOwner();
                list.Access.CreateGrantForPrimitive(User.GetEveryoneGroupKey(core), "VIEW");
                //Access.CreateAllGrantsForOwner(core, list);
                //Access.CreateGrantForPrimitive(core, list, new ItemKey(-2, ItemType.GetTypeId(typeof(User))), "VIEW");

                return list;
            }
            catch (PageSlugNotUniqueException)
            {
                throw new ListSlugNotUniqueException();
            }
        }
Esempio n. 6
0
 public static string BuildListUri(Core core, List list)
 {
     return core.Hyperlink.AppendSid(string.Format("{0}lists/{1}",
         list.owner.UriStub, list.path));
 }
Esempio n. 7
0
        public static List<NagivationTab> GetTabs(Core core, Primitive owner)
        {
            List<NagivationTab> tabs = new List<NagivationTab>();

            SelectQuery query = NagivationTab.GetSelectQueryStub(core, typeof(NagivationTab));
            query.AddCondition("tab_item_id", owner.Id);
            query.AddCondition("tab_item_type_id", owner.TypeId);
            query.AddSort(SortOrder.Ascending, "tab_order");

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

            while (tabReader.Read())
            {
                tabs.Add(new NagivationTab(core, tabReader));
            }

            tabReader.Close();
            tabReader.Dispose();

            return tabs;
        }
Esempio n. 8
0
        /// <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;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Add an item onto a list
        /// </summary>
        void AccountListsManage_Append(object sender, EventArgs e)
        {
            string text = core.Http.Form["text"];
            string slug = text; // normalised representation
            long listId = core.Functions.FormLong("id", 0);
            bool ajax = false;

            try
            {
                ajax = bool.Parse(core.Http["ajax"]);
            }
            catch { }

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

                try
                {
                    ListItem item = list.AddNew(text, ref slug);

                    ApplicationEntry ae = new ApplicationEntry(core);

                    // TODO: different list types
                    //core.CallingApplication.PublishToFeed(LoggedInMember, list.ItemKey, string.Format("added {0} to list [iurl={2}]{1}[/iurl]", item.Text, list.Title, list.Uri));

                    if (ajax)
                    {
                        core.Response.SendRawText("posted", text);

                        if (db != null)
                        {
                            db.CloseConnection();
                        }
                        core.Http.End();
                        return;
                    }
                    else
                    {
                        SetRedirectUri(core.Hyperlink.BuildListUri(LoggedInMember, list.Path));
                        core.Display.ShowMessage("List Updated", "You have successfully appended an item to your list.");
                    }
                }
                catch (UnauthorisedToCreateItemException)
                {
                    core.Response.ShowMessage("unauthorised", "Unauthorised", "You are unauthorised to append to this list.");
                    return;
                }

            }
            catch (InvalidListException)
            {
                core.Response.ShowMessage("error", "List Error", "You submitted invalid information. Go back and try again.");
                return;
            }
        }
Esempio n. 10
0
        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());
            }
        }
Esempio n. 11
0
        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));
        }
Esempio n. 12
0
        void AccountListsManage_Save(object sender, EventArgs e)
        {
            string title = core.Http.Form["title"];
            string slug = core.Http.Form["title"];
            string listAbstract = core.Http.Form["abstract"];
            short type = core.Functions.FormShort("type", 1);
            long listId = core.Functions.FormLong("id", 0);

            // new
            if (listId == 0)
            {
                try
                {
                    List newList = List.Create(core, title, ref slug, listAbstract, type);

                    SetRedirectUri(BuildUri("lists"));
                    core.Display.ShowMessage("List Created", "You have created a new list");
                    return;
                }
                catch (ListTypeNotValidException)
                {
                    core.Display.ShowMessage("List Error", "You submitted invalid information. Go back and try again.");
                    return;
                }
                catch (ListSlugNotUniqueException)
                {
                    core.Display.ShowMessage("List Error", "You have already created a list with the same name, go back and give another name.");
                    return;
                }
            }

            // edit
            if (listId > 0)
            {
                try
                {
                    List list = new List(core, session.LoggedInMember, listId);

                    string oldSlug = list.Path;

                    list.Title = title;
                    list.Abstract = listAbstract;
                    list.Type = type;

                    try
                    {
                        list.Update();

                        // Update page
                        try
                        {
                            Page listPage = new Page(core, core.Session.LoggedInMember, oldSlug, "lists");

                            listPage.Title = list.Title;
                            listPage.Slug = list.Path;

                            listPage.Update();
                        }
                        catch (PageNotFoundException)
                        {
                            Page listPage;
                            try
                            {
                                listPage = new Page(core, core.Session.LoggedInMember, "lists");
                            }
                            catch (PageNotFoundException)
                            {
                                string listSlug = "lists";
                                try
                                {
                                    listPage = Page.Create(core, core.Session.LoggedInMember, "Lists", ref listSlug, 0, "", PageStatus.PageList, 0, Classifications.None);
                                }
                                catch (PageSlugNotUniqueException)
                                {
                                    throw new Exception("Cannot create lists slug.");
                                }
                            }
                            slug = list.Path;
                            Page page = Page.Create(core, core.Session.LoggedInMember, title, ref slug, listPage.Id, "", PageStatus.PageList, 0, Classifications.None);
                        }

                        SetRedirectUri(core.Hyperlink.BuildAccountSubModuleUri(ModuleKey, "lists"));
                        core.Display.ShowMessage("List Saved", "You have saved the list");
                        return;
                    }
                    catch (UnauthorisedToUpdateItemException)
                    {
                        DisplayGenericError();
                        return;
                    }
                    catch (RecordNotUniqueException)
                    {
                        core.Display.ShowMessage("List Error", "You have already created a list with the same name, go back and give another name.");
                        return;
                    }
                }
                catch (InvalidListException)
                {
                    DisplayGenericError();
                    return;
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Remove an item from a list
        /// </summary>
        void AccountListsManage_Remove(object sender, EventArgs e)
        {
            AuthoriseRequestSid();

            long itemId = core.Functions.RequestLong("id", 0);
            try
            {
                ListItem item = new ListItem(core, itemId);
                List list = new List(core, LoggedInMember, item.ListId);

                List.Remove(core, item);

                SetRedirectUri(list.Uri);
                core.Display.ShowMessage("List Updated", "You have successfully removed an item from your list.");
            }
            catch (InvalidListItemException)
            {
                DisplayGenericError();
                return;
            }
            catch (UnauthorisedToDeleteItemException)
            {
                DisplayGenericError();
                return;
            }
        }
Esempio n. 14
0
        //public static void ShowLists(Core core, UPage page)
        public static void ShowLists(object sender, ShowPPageEventArgs e)
        {
            e.Template.SetTemplate("Pages", "viewlist");

            Page page = new Page(e.Core, e.Page.Owner, "lists");

            e.Core.Display.ParsePageList(e.Page.Owner, true, page);

            e.Template.Parse("USER_THUMB", e.Page.Owner.Thumbnail);
            e.Template.Parse("USER_COVER_PHOTO", e.Page.Owner.CoverPhoto);
            e.Template.Parse("USER_MOBILE_COVER_PHOTO", e.Page.Owner.MobileCoverPhoto);

            e.Template.Parse("LIST_TITLE", string.Format("{0} Lists", e.Page.Owner.DisplayNameOwnership));
            e.Template.Parse("LIST_ABSTRACT", "FALSE");

            List<List> lists = List.GetLists(e.Core, (User)e.Page.Owner);

            if (lists.Count > 0)
            {
                e.Template.Parse("NOT_EMPTY", "TRUE");
            }

            foreach (List list in lists)
            {
                VariableCollection listVariableCollection = e.Template.CreateChild("list_list");

                listVariableCollection.Parse("TITLE", list.Title);
                listVariableCollection.Parse("URI", List.BuildListUri(e.Core, list));
            }

            List<string[]> breadCrumbParts = new List<string[]>();
            breadCrumbParts.Add(new string[] { "lists", "Lists" });

            page.Owner.ParseBreadCrumbs(breadCrumbParts);
        }
Esempio n. 15
0
        private static void Show(Core core, Primitive owner, Page thePage)
        {
            core.Template.SetTemplate("Pages", "viewpage");

            core.Display.ParsePageList(owner, true, thePage);

            if (!thePage.Access.Can("VIEW"))
            {
                core.Functions.Generate403();
                return;
            }

            BoxSocial.Internals.Classification.ApplyRestrictions(core, thePage.Classification);

            core.Template.Parse("PAGE_TITLE", thePage.Title);

            if (!string.IsNullOrEmpty(thePage.BodyCache))
            {
                core.Display.ParseBbcodeCache("PAGE_BODY", thePage.BodyCache);
            }
            else
            {
                core.Display.ParseBbcode(core.Template, "PAGE_BODY", thePage.Body, thePage.Owner, true, null, null);
            }

            if (core.Session.LoggedInMember != null)
            {
                if (owner is User && owner.Id != core.Session.LoggedInMember.UserId)
                {
                    core.Db.UpdateQuery(string.Format("UPDATE user_pages SET page_views = page_views + 1 WHERE page_item_id = {0} AND page_item_type_id = {1} AND page_id = '{2}';",
                        owner.Id, owner.TypeId, thePage.PageId));
                }
                else
                {
                    core.Db.UpdateQuery(string.Format("UPDATE user_pages SET page_views = page_views + 1 WHERE page_item_id = {0} AND page_item_type_id = {1} AND page_id = '{2}';",
                        owner.Id, owner.TypeId, thePage.PageId));
                }
            }

            ItemView.LogView(core, thePage);

            if (thePage.License != null)
            {
                if (!string.IsNullOrEmpty(thePage.License.Title))
                {
                    core.Template.Parse("PAGE_LICENSE", thePage.License.Title);
                }
                if (!string.IsNullOrEmpty(thePage.License.Icon))
                {
                    core.Template.Parse("I_PAGE_LICENSE", thePage.License.Icon);
                }
                if (!string.IsNullOrEmpty(thePage.License.Link))
                {
                    core.Template.Parse("U_PAGE_LICENSE", thePage.License.Link);
                }
            }

            switch (thePage.Classification)
            {
                case Classifications.Everyone:
                    core.Template.Parse("PAGE_CLASSIFICATION", "Suitable for Everyone");
                    core.Template.Parse("I_PAGE_CLASSIFICATION", "rating_e.png");
                    break;
                case Classifications.Mature:
                    core.Template.Parse("PAGE_CLASSIFICATION", "Suitable for Mature Audiences 15+");
                    core.Template.Parse("I_PAGE_CLASSIFICATION", "rating_15.png");
                    break;
                case Classifications.Restricted:
                    core.Template.Parse("PAGE_CLASSIFICATION", "Retricted to Audiences 18+");
                    core.Template.Parse("I_PAGE_CLASSIFICATION", "rating_18.png");
                    break;
            }

            DateTime pageDateTime = thePage.GetModifiedDate(core.Tz);
            core.Template.Parse("PAGE_LAST_MODIFIED", core.Tz.DateTimeToString(pageDateTime));
            core.Template.Parse("PAGE_VIEWS", thePage.Views.ToString());
            core.Template.Parse("LAST_MODIFIED_PAGE_VIEWS", string.Format(core.Prose.GetString("LAST_MODIFIED_PAGE_VIEWS"), core.Tz.DateTimeToString(pageDateTime), thePage.Views.ToString()));

            List<string[]> breadCrumbParts = new List<string[]>();
            if (thePage.Parents != null)
            {
                foreach (ParentTreeNode ptn in thePage.Parents.Nodes)
                {
                    breadCrumbParts.Add(new string[] { ptn.ParentSlug, ptn.ParentTitle });
                }
            }

            if (thePage.Id > 0)
            {
                breadCrumbParts.Add(new string[] { thePage.Slug, thePage.Title });
            }

            owner.ParseBreadCrumbs(breadCrumbParts);

            if (thePage.Access.Can("EDIT"))
            {
                core.Template.Parse("U_EDIT", core.Hyperlink.BuildAccountSubModuleUri(owner, "pages", "write", "edit", thePage.PageId, true));
            }
        }
Esempio n. 16
0
        public static ListItem Create(Core core, List list, string text, ref string normalisedText)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            if (string.IsNullOrEmpty(normalisedText))
            {
                normalisedText = text;
            }

            if (!list.Access.Can("APPEND"))
            {
                throw new UnauthorisedToCreateItemException();
            }

            NormaliseListItem(text, ref normalisedText);

            core.Db.BeginTransaction();

            ListItemText lit;

            try
            {
                lit = new ListItemText(core, normalisedText);
            }
            catch (InvalidListItemTextException)
            {
                lit = ListItemText.Create(core, text, ref normalisedText);
            }

            InsertQuery iQuery = new InsertQuery(GetTable(typeof(ListItem)));
            iQuery.AddField("list_id", list.Id);
            iQuery.AddField("list_item_text_id", lit.Id);

            long listItemId = core.Db.Query(iQuery);

            return new ListItem(core, listItemId);
        }
Esempio n. 17
0
        /// <summary>
        /// Delete the list itself
        /// </summary>
        void AccountListsManage_Delete(object sender, EventArgs e)
        {
            AuthoriseRequestSid();

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

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

                try
                {
                    list.Delete();
                }
                catch (UnauthorisedToDeleteItemException)
                {
                    core.Display.ShowMessage("Cannot Delete", "You are unauthorised to delete this list");
                    return;
                }

                try
                {
                    Page listPage = new Page(core, core.Session.LoggedInMember, list.Path, "lists");

                    listPage.Delete();
                }
                catch (PageNotFoundException)
                {
                    // Can ignore
                }

                SetRedirectUri(core.Hyperlink.BuildAccountSubModuleUri(ModuleKey, "lists"));
                core.Display.ShowMessage("List Deleted", "You have deleted a list.");
                return;
            }
            catch (InvalidListException)
            {
                core.Display.ShowMessage("List Error", "You submitted invalid information. Go back and try again. List may have already been deleted.");
                return;
            }
        }