Fossil SCM
Show both the display name and the login on forum pages.
Commit
d5455f5b1b83d7d1aa688b69468b5c504eafa2948d22007247a7697c9b60c0e6
Parent
2e71dc25d94c3f9…
1 file changed
+8
-5
+8
-5
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -361,22 +361,25 @@ | ||
| 361 | 361 | ** If the input login is found in the USER table, then check the USER.INFO |
| 362 | 362 | ** field to see if it has display-name followed by an email address. |
| 363 | 363 | ** If it does, that becomes the new display name. If not, let the display |
| 364 | 364 | ** name just be the login. |
| 365 | 365 | ** |
| 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. | |
| 368 | 368 | */ |
| 369 | 369 | char *display_name_from_login(const char *zLogin){ |
| 370 | 370 | static Stmt q; |
| 371 | 371 | char *zResult; |
| 372 | 372 | 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" | |
| 374 | 374 | ); |
| 375 | 375 | 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 | + } | |
| 378 | 381 | db_reset(&q); |
| 379 | 382 | return zResult; |
| 380 | 383 | } |
| 381 | 384 | |
| 382 | 385 | |
| 383 | 386 |
| --- 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 |