Changeset 20309 for events

Show
Ignore:
Timestamp:
09/30/08 21:04:49 (2 months ago)
Author:
kenji
Message:

Add link to @username

Location:
events/phpframework/codeigniter/trunk/system/application
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • events/phpframework/codeigniter/trunk/system/application/models/status_model.php

    r20302 r20309  
    154154        function get_last_comment($id) 
    155155        { 
    156                 $this->db->select('SQL_CALC_FOUND_ROWS statuses.comment'); 
     156                $this->db->select('SQL_CALC_FOUND_ROWS statuses.comment, username AS reply_username'); 
    157157                $this->db->from('statuses'); 
     158                $this->db->join('users AS u2', 'statuses.reply_user_id = u2.id', 'left'); 
    158159                $this->db->where('user_id', $id); 
    159                 $this->db->order_by('created_at', 'DESC'); 
     160                $this->db->order_by('statuses.created_at', 'DESC'); 
    160161                $this->db->limit(1, 0); 
    161162                $query = $this->db->get(); 
     
    180181        function get_comment($id) 
    181182        { 
    182                 $this->db->select('statuses.id, username, comment, UNIX_TIMESTAMP(statuses.created_at) AS created_at, image'); 
     183                $this->db->select('SQL_CALC_FOUND_ROWS statuses.id, u1.username AS username, comment, u2.username AS reply_username, UNIX_TIMESTAMP(statuses.created_at) AS created_at, u1.image AS image'); 
    183184                $this->db->from('statuses'); 
    184                 $this->db->join('users', 'statuses.user_id = users.id', 'left'); 
     185                $this->db->join('users AS u1', 'statuses.user_id = u1.id', 'left'); 
     186                $this->db->join('users AS u2', 'statuses.reply_user_id = u2.id', 'left'); 
    185187                $this->db->where('statuses.id', $id); 
    186188                $this->db->limit(1, 0); 
  • events/phpframework/codeigniter/trunk/system/application/views/user/main_comment.php

    r19981 r20309  
    55                <?php foreach($list as $row):?> 
    66                                <p> 
    7                                 <?=h($row->comment)?> 
     7                                <?php  
     8                                        $row->comment = h($row->comment); 
     9                                        if ($row->reply_username) { 
     10                                                $row->comment = preg_replace('/^@(\w+)\s/', '@' . anchor(site_url('user/index/' . $row->reply_username), $row->reply_username) . ' ', $row->comment); 
     11                                        } 
     12                                ?> 
     13                                <?=$row->comment?> 
    814                                <?=posted_time($row->created_at)?> 
    915                                </p>