Fossil SCM

Show both the display name and the login on forum pages.

drh 2020-03-27 14:41 trunk
Commit d5455f5b1b83d7d1aa688b69468b5c504eafa2948d22007247a7697c9b60c0e6
1 file changed +8 -5
+8 -5
--- src/forum.c
+++ src/forum.c
@@ -361,22 +361,25 @@
361361
** If the input login is found in the USER table, then check the USER.INFO
362362
** field to see if it has display-name followed by an email address.
363363
** If it does, that becomes the new display name. If not, let the display
364364
** name just be the login.
365365
**
366
-** Space to hold the returned name is obtained form fossil_strdup()
367
-** and should be freed by the caller.
366
+** Space to hold the returned name is obtained from fossil_strdup() or
367
+** mprintf() and should be freed by the caller.
368368
*/
369369
char *display_name_from_login(const char *zLogin){
370370
static Stmt q;
371371
char *zResult;
372372
db_static_prepare(&q,
373
- "SELECT coalesce(display_name(info),$login) FROM user WHERE login=$login"
373
+ "SELECT display_name(info) FROM user WHERE login=$login"
374374
);
375375
db_bind_text(&q, "$login", zLogin);
376
- db_step(&q);
377
- zResult = fossil_strdup(db_column_text(&q,0));
376
+ if( db_step(&q)==SQLITE_ROW && db_column_type(&q,0)==SQLITE_TEXT ){
377
+ zResult = mprintf("%s (%s)", db_column_text(&q,0), zLogin);
378
+ }else{
379
+ zResult = fossil_strdup(zLogin);
380
+ }
378381
db_reset(&q);
379382
return zResult;
380383
}
381384
382385
383386
--- src/forum.c
+++ src/forum.c
@@ -361,22 +361,25 @@
361 ** If the input login is found in the USER table, then check the USER.INFO
362 ** field to see if it has display-name followed by an email address.
363 ** If it does, that becomes the new display name. If not, let the display
364 ** name just be the login.
365 **
366 ** Space to hold the returned name is obtained form fossil_strdup()
367 ** and should be freed by the caller.
368 */
369 char *display_name_from_login(const char *zLogin){
370 static Stmt q;
371 char *zResult;
372 db_static_prepare(&q,
373 "SELECT coalesce(display_name(info),$login) FROM user WHERE login=$login"
374 );
375 db_bind_text(&q, "$login", zLogin);
376 db_step(&q);
377 zResult = fossil_strdup(db_column_text(&q,0));
 
 
 
378 db_reset(&q);
379 return zResult;
380 }
381
382
383
--- src/forum.c
+++ src/forum.c
@@ -361,22 +361,25 @@
361 ** If the input login is found in the USER table, then check the USER.INFO
362 ** field to see if it has display-name followed by an email address.
363 ** If it does, that becomes the new display name. If not, let the display
364 ** name just be the login.
365 **
366 ** Space to hold the returned name is obtained from fossil_strdup() or
367 ** mprintf() and should be freed by the caller.
368 */
369 char *display_name_from_login(const char *zLogin){
370 static Stmt q;
371 char *zResult;
372 db_static_prepare(&q,
373 "SELECT display_name(info) FROM user WHERE login=$login"
374 );
375 db_bind_text(&q, "$login", zLogin);
376 if( db_step(&q)==SQLITE_ROW && db_column_type(&q,0)==SQLITE_TEXT ){
377 zResult = mprintf("%s (%s)", db_column_text(&q,0), zLogin);
378 }else{
379 zResult = fossil_strdup(zLogin);
380 }
381 db_reset(&q);
382 return zResult;
383 }
384
385
386

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button