Skip to content

Commit

Permalink
Fixes #3971 - Display issue with anonymous posts in Comment Manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Nov 28, 2020
1 parent 5f43f51 commit 22653b3
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions e107_admin/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ class comments_admin_ui extends e_admin_ui
'comment_item_id' => array('title'=> LAN_ITEM, 'type' => 'text', 'readonly'=>2, 'data'=>'int', 'width' => '5%'),
'comment_subject' => array('title'=> LAN_SUBJECT, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first', 'writeParms'=>array('size'=>'xxlarge')), // Display name
'comment_comment' => array('title'=> LAN_COMMENTS, 'type' => 'textarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1', 'writeParms'=>'size=xxlarge'), // Display name
'comment_author_id' => array('title'=> LAN_AUTHOR, 'type' => 'user', 'data' => 'int', 'width' => 'auto', 'writeParms' => 'nameField=comment_author_name'), // User id
'comment_author_name' => array('title'=> LAN_USER, 'type' => 'text', 'width' => 'auto', 'readParms'=>'idField=comment_author_id&link=1', 'noedit' => true, 'forceSave' => true), // User name
'comment_author_id' => array('title'=> LAN_AUTHOR, 'type' => 'method', 'data' => 'int', 'width' => 'auto', 'writeParms' => 'nameField=comment_author_name'), // User id
'comment_author_name' => array('title'=> LAN_USER, 'type' => 'text', 'nolist'=>true, 'width' => 'auto', 'readParms'=>'idField=comment_author_id&link=1', 'noedit' => true, 'forceSave' => true), // User name
'u.user_name' => array('title'=> LAN_SYSTEM_USER, 'type' => 'user', 'width' => 'auto', 'readParms'=>'idField=comment_author_id&link=1', 'noedit' => true), // User name
'comment_datestamp' => array('title'=> LAN_DATESTAMP, 'type' => 'datestamp', 'width' => 'auto'), // User date
'comment_ip' => array('title'=> LAN_IP, 'type' => 'ip', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting)
'comment_lock' => array('title'=> LAN_LOCK, 'type' => 'boolean', 'data'=> 'int', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'width' => 'auto'),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center')
);
//required (but should be optional) - default column user prefs
protected $fieldpref = array('checkboxes', 'comment_id', 'comment_item_id', 'comment_author_id', 'comment_author_name', 'comment_subject', 'comment_comment', 'comment_type', 'options');
protected $fieldpref = array('checkboxes', 'comment_id', 'comment_item_id', 'comment_author_id', 'comment_author_name', 'user_name', 'comment_subject', 'comment_comment', 'comment_type', 'options');


// optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName);
Expand Down Expand Up @@ -151,10 +151,9 @@ public function afterUpdate($new_data, $old_data, $id)
public function beforeUpdate($new_data, $old_data, $id)
{

if(is_numeric($new_data['comment_author_name']) && !empty($new_data['comment_author_name']))
if(is_numeric($new_data['comment_author_id']) && !empty($new_data['comment_author_id']))
{
$userData = e107::user($new_data['comment_author_name']);
$new_data['comment_author_id'] = $new_data['comment_author_name'];
$userData = e107::user($new_data['comment_author_id']);
$new_data['comment_author_name'] = $userData['user_name'];
}

Expand Down Expand Up @@ -311,6 +310,31 @@ function comment_blocked($curVal,$mode, $parms) // not really necessary since we

}

function comment_author_id($curVal,$mode, $parms) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
{
switch ($mode)
{
case "read":
return $this->getController()->getFieldVar('comment_author_name');
break;

case "write":

if(empty($curVal))
{
$value = $this->getController()->getFieldVar('comment_author_name');
return $this->text('comment_author_name', $value);
}

return $this->userpicker('comment_author_id', $curVal);
break;

default:
// code to be executed if n is different from all labels;
}

}


}

Expand Down

0 comments on commit 22653b3

Please sign in to comment.