From c83ac65f7e7f0f1cb32c84c385431174b8ff1369 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Mon, 26 Jan 2026 16:11:05 -0700 Subject: [PATCH] conference sidebox is now filled in --- database/community.go | 3 ++- database/contactinfo.go | 9 ++++++++- database/emailban.go | 6 ++++-- database/globals.go | 6 ++++-- database/user.go | 26 +++++++++++++------------- docs/MISSINGFUNCS.md | 6 ++++-- top.go | 1 + ui/views/sb_ftrconf.jet | 7 +++++++ 8 files changed, 43 insertions(+), 21 deletions(-) diff --git a/database/community.go b/database/community.go index d5decb2..a277d2b 100644 --- a/database/community.go +++ b/database/community.go @@ -880,7 +880,8 @@ func AmCreateCommunity(ctx context.Context, name string, alias string, hostUid i // validate alias does not already exist row := tx.QueryRowContext(ctx, "SELECT commid FROM communities WHERE alias = ?", alias) - err := row.Err() + var tmpcid int32 + err := row.Scan(&tmpcid) if err != sql.ErrNoRows { if err == nil { err = errors.New("a community with that alias already exists") diff --git a/database/contactinfo.go b/database/contactinfo.go index b4f1e69..15d5732 100644 --- a/database/contactinfo.go +++ b/database/contactinfo.go @@ -56,6 +56,9 @@ func lookupCommunityContact(ctx context.Context, id int32) (int32, error) { var rc int32 = -1 row := amdb.QueryRowContext(ctx, "SELECT contactid FROM contacts WHERE owner_commid = ?", id) err := row.Scan(&rc) + if err == sql.ErrNoRows { + return -1, nil + } return rc, err } @@ -64,6 +67,9 @@ func lookupUserContact(ctx context.Context, uid int32) (int32, error) { var rc int32 = -1 row := amdb.QueryRowContext(ctx, "SELECT contactid FROM contacts WHERE owner_uid = ? AND owner_commid = -1", uid) err := row.Scan(&rc) + if err == sql.ErrNoRows { + return -1, nil + } return rc, err } @@ -143,7 +149,8 @@ func (ci *ContactInfo) Save(ctx context.Context) (bool, error) { if !emailChange { // we don't THINK the E-mail address is changing, but we could be wrong... row := amdb.QueryRowContext(ctx, "SELECT contactid FROM contacts WHERE contactid = ? AND email = ?", ci.ContactId, ci.Email) - err := row.Err() + var tmpcid int32 + err := row.Scan(&tmpcid) if err == sql.ErrNoRows { emailChange = true } else if err != nil { diff --git a/database/emailban.go b/database/emailban.go index b013748..c852853 100644 --- a/database/emailban.go +++ b/database/emailban.go @@ -24,11 +24,13 @@ import ( */ func AmIsEmailAddressBanned(ctx context.Context, address string) (bool, error) { row := amdb.QueryRowContext(ctx, "SELECT by_uid FROM emailban WHERE address = ?", address) - switch row.Err() { + var uid int32 + err := row.Scan(&uid) + switch err { case nil: return true, nil case sql.ErrNoRows: return false, nil } - return false, row.Err() + return false, err } diff --git a/database/globals.go b/database/globals.go index bda9f1d..fc749dd 100644 --- a/database/globals.go +++ b/database/globals.go @@ -146,13 +146,15 @@ func AmSetGlobalProperty(ctx context.Context, index int32, value string) error { _, updateMode := globalProps[index] if !updateMode { row := amdb.QueryRowContext(ctx, "SELECT data FROM propglobal WHERE ndx = ?", index) - switch row.Err() { + var tmpdata string + err := row.Scan(&tmpdata) + switch err { case nil: updateMode = true case sql.ErrNoRows: updateMode = false default: - return row.Err() + return err } } var err error = nil diff --git a/database/user.go b/database/user.go index 981583e..4b88bbf 100644 --- a/database/user.go +++ b/database/user.go @@ -698,31 +698,32 @@ func AmCreateNewUser(ctx context.Context, username string, password string, remi // Test if the user name is already taken. row := tx.QueryRowContext(ctx, "SELECT uid FROM users WHERE username = ?", username) - if row.Err() == nil { + var tmpuid int32 + err := row.Scan(&tmpuid) + if err == nil { log.Warnf("username \"%s\" already exists", username) return nil, errors.New("that user name already exists. Please try again") - } else if row.Err() != sql.ErrNoRows { - return nil, row.Err() + } else if err != sql.ErrNoRows { + return nil, err } // Insert the user record. - _, err2 := tx.ExecContext(ctx, `INSERT INTO users (username, passhash, verify_email, lockout, email_confnum, + _, err = tx.ExecContext(ctx, `INSERT INTO users (username, passhash, verify_email, lockout, email_confnum, base_lvl, created, lastaccess, passreminder, description, dob) VALUES (?, ?, 0, 0, ?, ?, NOW(), NOW(), ?, '', ?)`, username, hashPassword(password), util.GenerateRandomConfirmationNumber(), AmDefaultRole("Global.NewUser").Level(), reminder, dob) - if err2 != nil { - return nil, err2 + if err != nil { + return nil, err } // Read back the user, which also puts it in the cache. - user, err3 := AmGetUserByName(ctx, username, tx) - if err3 != nil { - return nil, err3 + user, err := AmGetUserByName(ctx, username, tx) + if err != nil { + return nil, err } log.Debugf("...created new user \"%s\" with UID %d", username, user.Uid) // add user preferences - _, err := tx.ExecContext(ctx, "INSERT INTO userprefs (uid) VALUES (?)", user.Uid) - if err != nil { + if _, err = tx.ExecContext(ctx, "INSERT INTO userprefs (uid) VALUES (?)", user.Uid); err != nil { return nil, err } @@ -732,8 +733,7 @@ func AmCreateNewUser(ctx context.Context, username string, password string, remi return nil, err } for _, p := range props { - _, err := tx.ExecContext(ctx, "INSERT INTO propuser (uid, ndx, data) VALUES (?, ?, ?)", user.Uid, p.Index, p.Data) - if err != nil { + if _, err = tx.ExecContext(ctx, "INSERT INTO propuser (uid, ndx, data) VALUES (?, ?, ?)", user.Uid, p.Index, p.Data); err != nil { return nil, err } } diff --git a/docs/MISSINGFUNCS.md b/docs/MISSINGFUNCS.md index f8d8ddf..d7fdf2a 100644 --- a/docs/MISSINGFUNCS.md +++ b/docs/MISSINGFUNCS.md @@ -5,7 +5,7 @@ - Error handling: shift titles and templates for different error codes - Find Posts - Services mechanism: Conference vtable -- User creation: copy conference hotlists +- ~~User creation: copy conference hotlists ~~ - Calendar (top menu link) - Chat (top menu link) - Documentation (top menu link) @@ -41,7 +41,9 @@ - Post Move - Post Publish - Manage Communities on communities sidebox -- Conference Hotlist sidebox +- ~~Conference Hotlist sidebox~~ +- "New" flag on Conference Hotlist sidebox +- Manage on Conference Hotlist sidebox - Sidebox configuration - Topics view: - Find diff --git a/top.go b/top.go index 41b4714..36ce6aa 100644 --- a/top.go +++ b/top.go @@ -136,6 +136,7 @@ func buildFeaturedConferences(ctxt ui.AmContext, uid int32, out *RenderedSidebox // TODO: add "New" indicator } out.Flags = make(map[string]bool) + out.Flags["canManage"] = !(user.IsAnon) out.TemplateName = "sb_ftrconf.jet" } } diff --git a/ui/views/sb_ftrconf.jet b/ui/views/sb_ftrconf.jet index 7067364..02b1b4b 100644 --- a/ui/views/sb_ftrconf.jet +++ b/ui/views/sb_ftrconf.jet @@ -28,5 +28,12 @@
No conferences in hotlist.
{{ end }} + {{ if sb.Flags["canManage"] }} +
+ + [ Manage ] + +
+ {{ end }}