| | @@ -352,10 +352,35 @@ |
| 352 | 352 | @ Trust user "%h(pPost->zUser)" |
| 353 | 353 | @ so that future posts by "%h(pPost->zUser)" do not require moderation. |
| 354 | 354 | @ </label> |
| 355 | 355 | @ <input type="hidden" name="trustuser" value="%h(pPost->zUser)"> |
| 356 | 356 | } |
| 357 | + |
| 358 | +/* |
| 359 | +** Compute a display name from a login name. |
| 360 | +** |
| 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 | + |
| 357 | 382 | |
| 358 | 383 | /* |
| 359 | 384 | ** Display all posts in a forum thread in chronological order |
| 360 | 385 | */ |
| 361 | 386 | static void forum_display_chronological(int froot, int target, int bRawMode){ |
| | @@ -367,10 +392,11 @@ |
| 367 | 392 | char *zDate; |
| 368 | 393 | Manifest *pPost; |
| 369 | 394 | int isPrivate; /* True for posts awaiting moderation */ |
| 370 | 395 | int sameUser; /* True if author is also the reader */ |
| 371 | 396 | const char *zUuid; |
| 397 | + char *zDisplayName; /* The display name */ |
| 372 | 398 | |
| 373 | 399 | pPost = manifest_get(p->fpid, CFTYPE_FORUM, 0); |
| 374 | 400 | if( pPost==0 ) continue; |
| 375 | 401 | if( p->fpid==target ){ |
| 376 | 402 | @ <div id="forum%d(p->fpid)" class="forumTime forumSel"> |
| | @@ -381,11 +407,13 @@ |
| 381 | 407 | } |
| 382 | 408 | if( pPost->zThreadTitle ){ |
| 383 | 409 | @ <h1>%h(pPost->zThreadTitle)</h1> |
| 384 | 410 | } |
| 385 | 411 | zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate); |
| 386 | | - @ <h3 class='forumPostHdr'>(%d(p->sid)) By %h(pPost->zUser) on %h(zDate) |
| 412 | + zDisplayName = display_name_from_login(pPost->zUser); |
| 413 | + @ <h3 class='forumPostHdr'>(%d(p->sid)) By %h(zDisplayName) on %h(zDate) |
| 414 | + fossil_free(zDisplayName); |
| 387 | 415 | fossil_free(zDate); |
| 388 | 416 | if( p->pEdit ){ |
| 389 | 417 | @ edit of %z(href("%R/forumpost/%S?t=%c",p->pEdit->zUuid,cMode))\ |
| 390 | 418 | @ %d(p->pEdit->sid)</a> |
| 391 | 419 | } |
| | @@ -479,10 +507,11 @@ |
| 479 | 507 | iIndentScale--; |
| 480 | 508 | } |
| 481 | 509 | for(p=pThread->pDisplay; p; p=p->pDisplay){ |
| 482 | 510 | int isPrivate; /* True for posts awaiting moderation */ |
| 483 | 511 | int sameUser; /* True if reader is also the poster */ |
| 512 | + char *zDisplayName; /* User name to be displayed */ |
| 484 | 513 | pOPost = manifest_get(p->fpid, CFTYPE_FORUM, 0); |
| 485 | 514 | if( p->pLeaf ){ |
| 486 | 515 | fpid = p->pLeaf->fpid; |
| 487 | 516 | zUuid = p->pLeaf->zUuid; |
| 488 | 517 | pPost = manifest_get(fpid, CFTYPE_FORUM, 0); |
| | @@ -502,12 +531,14 @@ |
| 502 | 531 | if( pPost==0 ) continue; |
| 503 | 532 | if( pPost->zThreadTitle ){ |
| 504 | 533 | @ <h1>%h(pPost->zThreadTitle)</h1> |
| 505 | 534 | } |
| 506 | 535 | zDate = db_text(0, "SELECT datetime(%.17g)", pOPost->rDate); |
| 536 | + zDisplayName = display_name_from_login(pOPost->zUser); |
| 507 | 537 | @ <h3 class='forumPostHdr'>\ |
| 508 | | - @ (%d(p->pLeaf?p->pLeaf->sid:p->sid)) By %h(pOPost->zUser) on %h(zDate) |
| 538 | + @ (%d(p->pLeaf?p->pLeaf->sid:p->sid)) By %h(zDisplayName) on %h(zDate) |
| 539 | + fossil_free(zDisplayName); |
| 509 | 540 | fossil_free(zDate); |
| 510 | 541 | if( g.perm.Debug ){ |
| 511 | 542 | @ <span class="debug">\ |
| 512 | 543 | @ <a href="%R/artifact/%h(p->zUuid)">(artifact)</a></span> |
| 513 | 544 | } |
| | @@ -1065,19 +1096,22 @@ |
| 1065 | 1096 | @ <input type="hidden" name="edit" value="1"> |
| 1066 | 1097 | forum_from_line(); |
| 1067 | 1098 | forum_entry_widget(zTitle, zMimetype, zContent); |
| 1068 | 1099 | }else{ |
| 1069 | 1100 | /* Reply */ |
| 1101 | + char *zDisplayName; |
| 1070 | 1102 | zMimetype = PD("mimetype",DEFAULT_FORUM_MIMETYPE); |
| 1071 | 1103 | zContent = PDT("content",""); |
| 1072 | 1104 | style_header("Reply"); |
| 1073 | 1105 | if( pRootPost->zThreadTitle ){ |
| 1074 | 1106 | @ <h1>Thread: %h(pRootPost->zThreadTitle)</h1> |
| 1075 | 1107 | } |
| 1076 | 1108 | @ <h2>Replying To:</h2> |
| 1077 | 1109 | zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate); |
| 1078 | | - @ <h3 class='forumPostHdr'>By %h(pPost->zUser) on %h(zDate)</h3> |
| 1110 | + zDisplayName = display_name_from_login(pPost->zUser); |
| 1111 | + @ <h3 class='forumPostHdr'>By %h(zDisplayName) on %h(zDate)</h3> |
| 1112 | + fossil_free(zDisplayName); |
| 1079 | 1113 | fossil_free(zDate); |
| 1080 | 1114 | forum_render(0, pPost->zMimetype, pPost->zWiki, "forumEdit"); |
| 1081 | 1115 | if( P("preview") ){ |
| 1082 | 1116 | @ <h2>Preview:</h2> |
| 1083 | 1117 | forum_render(0, zMimetype,zContent, "forumEdit"); |
| 1084 | 1118 | |