From 831c6c5524ab6550d0fb848794904e6c0c25163d Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Thu, 19 Feb 2026 23:02:03 -0700 Subject: [PATCH] on manage conference list, wired up "move up," "move down," and "show/hide" commands --- conferenceadmin.go | 36 ++++++++++++++++++++++++++++++++++++ database/conference.go | 26 ++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/conferenceadmin.go b/conferenceadmin.go index 6910be6..2cf8511 100644 --- a/conferenceadmin.go +++ b/conferenceadmin.go @@ -803,11 +803,47 @@ func ManageConferenceList(ctxt ui.AmContext) (string, any) { return "error", ENOPERM } + if ctxt.HasParameter("t") { + confid := ctxt.QueryParamInt("t", -1) + if confid == -1 { + return "error", EINVAL + } + conf, err := database.AmGetConference(ctxt.Ctx(), int32(confid)) + if err != nil { + return "error", err + } + f, err := conf.HiddenInList(ctxt.Ctx(), comm) + if err == nil { + err = conf.SetHiddenInList(ctxt.Ctx(), comm, !f) + } + if err != nil { + return "error", err + } + } + clist, err := database.AmListConferences(ctxt.Ctx(), comm.Id, true) if err != nil { return "error", err } + if ctxt.HasParameter("m") { + index := ctxt.QueryParamInt("m", -1) + if index == -1 { + return "error", EINVAL + } + delta := ctxt.QueryParamInt("n", 0) + if delta == 0 { + return "error", EINVAL + } + err = database.AmReorderConferences(ctxt.Ctx(), comm.Id, clist[index].Sequence, clist[index+delta].Sequence) + if err != nil { + return "error", err + } + tmp := clist[index] + clist[index] = clist[index+delta] + clist[index+delta] = tmp + } + ntopics := make([]int, len(clist)) nposts := make([]int, len(clist)) for i, c := range clist { diff --git a/database/conference.go b/database/conference.go index be3ce60..d15d917 100644 --- a/database/conference.go +++ b/database/conference.go @@ -1007,6 +1007,32 @@ func AmSetConferenceProperty(ctx context.Context, confid int32, ndx int32, val * return err } +// AmReorderConferences reorders two conferences by sequence number. +func AmReorderConferences(ctx context.Context, cid int32, seq1, seq2 int16) error { + success := false + tx := amdb.MustBegin() + defer func() { + if !success { + tx.Rollback() + } + }() + _, err := tx.ExecContext(ctx, "UPDATE commtoconf SET sequence = -1 WHERE commid = ? AND sequence = ?", cid, seq1) + if err == nil { + _, err = tx.ExecContext(ctx, "UPDATE commtoconf SET sequence = ? WHERE commid = ? AND sequence = ?", seq1, cid, seq2) + if err == nil { + _, err = tx.ExecContext(ctx, "UPDATE commtoconf SET sequence = ? WHERE commid = ? AND sequence = -1", seq2, cid) + } + } + if err != nil { + return err + } + if err = tx.Commit(); err != nil { + return err + } + success = true + return nil +} + /* AmCreateConference creates a new conference. * Parameters: * ctx - Standard Go context value.