Skip to content

Commit

Permalink
Fixed 2 issues with regards to incorrect user image showing for comment
Browse files Browse the repository at this point in the history
For issue #1072
  • Loading branch information
eSilverStrike committed Jan 14, 2022
1 parent 07196cf commit d30fd53
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions public_html/lib-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -4740,8 +4740,8 @@ function COM_getDisplayName($uid = 0, $username = '', $fullname = '', $remoteUse
$uid = 1;
}

// When an anonymous user has saved his/her user name to a cookie, then use it instead
if (($uid === 1) && isset($_COOKIE[$_CONF['cookie_anon_name']])) {
// When an anonymous user (and is the current user for this check) has saved his/her user name to a cookie, then use it instead
if (COM_isAnonUser() && isset($_COOKIE[$_CONF['cookie_anon_name']])) {
$username = GLText::stripTags($_COOKIE[$_CONF['cookie_anon_name']]);
$username = COM_checkWords($username, 'comment');
$username = GLText::remove4byteUtf8Chars($username);
Expand Down
58 changes: 29 additions & 29 deletions system/lib-comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,29 +303,32 @@ function CMT_getComment(&$comments, $mode, $type, $order, $delete_option = false
}

if ($preview) {
// Means array is post variables
// These should all have been filtered already
$A = $comments;
if (empty($A['nice_date'])) {
$A['nice_date'] = time();
}
if (!isset($A['cid'])) {
$A['cid'] = 0;
}
if (empty($A['photo'])) {
if (isset($_USER['photo'])) {
$A['photo'] = $_USER['photo'];
} else {
$A['photo'] = '';
}
}
if (empty($A['email'])) {
if (isset($_USER['email'])) {
$A['email'] = $_USER['email'];
} else {
$A['email'] = '';
}
}
// Means array is post variables
// These should all have been filtered already
$A = $comments;
if (empty($A['nice_date'])) {
$A['nice_date'] = time();
}
if (!isset($A['cid'])) {
$A['cid'] = 0;
}

// Need to check to see if comment being edited and previewed belongs to user doing the editing
if (empty($A['photo']) && ($A['uid'] == $_USER['uid'])) {
if (isset($_USER['photo'])) {
$A['photo'] = $_USER['photo'];
} else {
$A['photo'] = '';
}
}
if (empty($A['email'])) {
if (isset($_USER['email'])) {
$A['email'] = $_USER['email'];
} else {
$A['email'] = '';
}
}

$mode = 'flat';
} else {
$A = DB_fetchArray($comments);
Expand Down Expand Up @@ -376,10 +379,9 @@ function CMT_getComment(&$comments, $mode, $type, $order, $delete_option = false
if (!empty($A['fullname'])) {
$fullname = $A['fullname'];
}
$fullname = COM_getDisplayName($A['uid'], $A['username'],
$fullname);
$fullname = COM_getDisplayName($A['uid'], $A['username'], $fullname);
$template->set_var('author', $fullname);
$altText = $fullname;
$altText = $fullname;
$photo = '';
if ($_CONF['allow_user_photo']) {
$photo = USER_getPhoto($A['uid'], $A['photo'], $A['email'], PLG_getThemeItem('comment-width-user-avatar', 'comment'), PLG_getThemeItem('comment-css-user-avatar', 'comment'));
Expand Down Expand Up @@ -1102,9 +1104,7 @@ function CMT_commentForm($title, $comment, $sid, $pid, $type, $mode, $postMode,
}

if (($commentUid != 1) || empty($A[CMT_USERNAME])) {
//if (!($mode == $LANG03[14] || $mode == $LANG03[28] || $mode == $LANG03[34])) { // Preview mode
$A[CMT_USERNAME] = DB_getItem($_TABLES['users'], 'username', "uid = $commentUid");
//}
$A[CMT_USERNAME] = DB_getItem($_TABLES['users'], 'username', "uid = $commentUid");
}

if (COMMENT_ON_SAME_PAGE) {
Expand Down

0 comments on commit d30fd53

Please sign in to comment.