void AccountNavigationTabs_Move(object sender, ModuleModeEventArgs e)
        {
            AuthoriseRequestSid();

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

            try
            {
                NagivationTab tab = new NagivationTab(core, tabId);

                switch (e.Mode)
                {
                    case "move-up":
                        tab.MoveUp();

                        SetRedirectUri(BuildUri());
                        core.Display.ShowMessage("Tab Moved", "You have successfully moved the tab up one place.");
                        break;
                    case "move-down":
                        tab.MoveDown();

                        SetRedirectUri(BuildUri());
                        core.Display.ShowMessage("Tab Moved", "You have successfully moved the tab down one place.");
                        break;
                }
            }
            catch (InvalidNavigationTabException)
            {
                DisplayGenericError();
            }
        }
Example #2
0
        public static NagivationTab Create(Core core, Page page)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            byte order = 0;

            SelectQuery query = NagivationTab.GetSelectQueryStub(core, typeof(NagivationTab));
            query.AddCondition("tab_item_id", page.Owner.Id);
            query.AddCondition("tab_item_type_id", page.Owner.TypeId);
            query.AddSort(SortOrder.Descending, "tab_order");
            query.LimitCount = 1;

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

            if (tabOrderTable.Rows.Count == 1)
            {
                NagivationTab tab = new NagivationTab(core, tabOrderTable.Rows[0]);

                order = (byte)(tab.Order + 1);
            }

            InsertQuery iQuery = new InsertQuery(NagivationTab.GetTable(typeof(NagivationTab)));
            iQuery.AddField("tab_page_id", page.Id);
            iQuery.AddField("tab_item_id", page.Owner.Id);
            iQuery.AddField("tab_item_type_id", page.Owner.TypeId);
            iQuery.AddField("tab_order", order);

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

            return new NagivationTab(core, tabId);
        }
        void AccountNavigationTabs_Delete(object sender, ModuleModeEventArgs e)
        {
            AuthoriseRequestSid();

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

            Dictionary<string, string> hiddenFields = new Dictionary<string, string>();
            hiddenFields.Add("key", ModuleKey);
            hiddenFields.Add("sub", Key);
            hiddenFields.Add("mode", "delete");

            if (core.Display.ShowConfirmBox(core.Hyperlink.AppendSid(Owner.AccountUriStub, true), "Delete?", "Are you sure you want to delete this tab?", hiddenFields) == ConfirmBoxResult.Yes)
            {
                try
                {
                    NagivationTab tab = new NagivationTab(core, tabId);

                    tab.Delete();

                    SetRedirectUri(BuildUri());
                    core.Display.ShowMessage("Tab Deleted", "You have successfully deleted the navigation tab.");
                }
                catch (InvalidNavigationTabException)
                {
                    DisplayGenericError();
                }
            }
            else
            {
                SetRedirectUri(BuildUri());
                core.Display.ShowMessage("Tab Not Deleted", "You have aborted deleting the navigation tab.");
            }
        }