on manage conference list, wired up "move up," "move down," and "show/hide" commands
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user