From 22653b3e3786a26d70daba013ab9b76c594d6ba5 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 28 Nov 2020 13:28:39 -0800 Subject: [PATCH] Fixes #3971 - Display issue with anonymous posts in Comment Manager. --- e107_admin/comment.php | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/e107_admin/comment.php b/e107_admin/comment.php index bf7414b8b0..69f71674db 100644 --- a/e107_admin/comment.php +++ b/e107_admin/comment.php @@ -79,8 +79,8 @@ 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) @@ -88,7 +88,7 @@ class comments_admin_ui extends e_admin_ui '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); @@ -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']; } @@ -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; + } + + } + }