每当评论任何问题,最后评论用户名不更新的问题


Whenever comment on any issue, last comment username not update in issues

无论何时评论任何一个问题,评论保存成功。

注释下面给出的保存代码:

$user = elgg_get_logged_in_user_entity();
$p_url = parse_url($_SERVER['HTTP_REFERER']);
if($p_url['path'] == '/issues/view' || $p_url['path'] == '/issues/respond')
    $tracker_comment = TRUE;
else
    $tracker_comment = FALSE;
if($tracker_comment)
{
    action_gatekeeper();
    // Get input
    $entity_guid = (int) get_input('entity_guid');
    $comment_text = get_input('generic_comment');
    // Let's see if we can get an entity with the specified GUID
    if ($entity = get_entity($entity_guid)) {
        $comment = new ElggComment();
        $comment->description = $comment_text;
        $comment->owner_guid = $user->getGUID();
        $comment->container_guid = $entity->getGUID();
        $comment->access_id = $entity->access_id;
        $guid = $comment->save();
        // If posting the comment was successful, say so
        if ($guid) {
            system_message(elgg_echo("generic_comment:posted"));
        } else {
            register_error(elgg_echo("generic_comment:failure"));
        }
    } else {
        register_error(elgg_echo("generic_comment:notfound"));
    }
    // Forward to the
    forward($entity->getURL());
}
else
    RETURN TRUE;

我无法检索问题列表中未更新的最后评论用户名。我使用elgg_get_annotation()来检索最后的评论详细信息。
但没有检索细节。最后的注释代码在下面给出。

if ($table_rows) {
foreach ( $table_rows as $entity ) {
    if ($entity->unread == 1) {
        $unread = "Yes";
    } else {
        $unread = "No";
    }
    if ($entity->assigned_to == 0) {
        $assigned = "No";
    } else {
        $assigned = "Yes";
    }
    $last_options = array ();
    $comments = elgg_get_annotations(array(
            'annotation_names' => 'issue_tracker_changes',
            'guid' =>  $entity->guid,
            'limit' => 1,
            'order_by' => 'n_table.id DESC',
    ));
    foreach ( $comments as $comment ) {
        $last_comment = get_entity ( $comment->owner_guid );
    }

自Elgg 1.9起,注释不再是注释,而是实体。您正在使用代表实体的ElggComment类创建评论,因此您正在使用elgg1.9或更新版本。你只需要用elgg_get_entities代替elgg_get_annotations。使用类型object和子类型comment