Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

Commit

Permalink
Add option to display usernames instead of real names.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnsl committed Jan 18, 2012
1 parent e909205 commit 993472d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions administrator/components/com_slicomments/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,17 @@
<option value="0">JNONE</option>
</field>

<field
name="field_name"
type="list"
label="COM_COMMENTS_FIELD_NAME_LABEL"
description="COM_COMMENTS_FIELD_NAME_DESC"
default="name"
validate="options">
<option value="name">COM_COMMENTS_OPTION_NAME</option>
<option value="username">COM_COMMENTS_OPTION_USERNAME</option>
</field>

<field
name="link"
type="components"
Expand Down
4 changes: 4 additions & 0 deletions administrator/language/en-GB/en-GB.com_slicomments.ini
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ COM_COMMENTS_LIMIT_LABEL="Comments per page"
COM_COMMENTS_LIMIT_DESC="Number of comments displayed on one page. To disable pagination set the value to all."
COM_COMMENTS_TOP_COMMENTS_LABEL="Top Comments"
COM_COMMENTS_TOP_COMMENTS_DESC="The maximun number of Top Comments to display."
COM_COMMENTS_FIELD_NAME_LABEL="Name field"
COM_COMMENTS_FIELD_NAME_DESC="The name to be displayed in the comments for logged-in users."
COM_COMMENTS_OPTION_NAME="Name"
COM_COMMENTS_OPTION_USERNAME="Login Name"
COM_COMMENTS_LINK_LABEL="Link names"
COM_COMMENTS_LINK_DESC="Link the user's name to their profile in another component."
COM_COMMENTS_AVATAR_LABEL="Avatar"
Expand Down
6 changes: 5 additions & 1 deletion components/com_slicomments/models/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,16 @@ protected function getStoreId($id = '')
*/
protected function getListQuery()
{
// Name or Username?
$field = $this->params->get('field_name', 'name');
if (!in_array($field, array('name', 'username'))) $field = 'name';

// Create a new query object.
$db = $this->_db;
$query = $db->getQuery(true);

// Select the required fields from the table.
$query->select('CASE WHEN a.user_id = 0 THEN a.name ELSE u.name END as name, CASE WHEN a.user_id = 0 THEN a.email ELSE u.email END as email, a.text, a.id, a.rating, a.user_id, a.created');
$query->select('CASE WHEN a.user_id = 0 THEN a.name ELSE u.'.$field.' END as name, CASE WHEN a.user_id = 0 THEN a.email ELSE u.email END as email, a.text, a.id, a.rating, a.user_id, a.created');
$query->from('#__slicomments AS a');

$query->leftjoin('#__users AS u ON u.id = a.user_id');
Expand Down

0 comments on commit 993472d

Please sign in to comment.