Development

Changeset 4016

You must first sign up to be able to contribute.

Changeset 4016

Show
Ignore:
Timestamp:
05/16/07 12:54:00 (1 year ago)
Author:
superhaggis
Message:

Added shortcut method to access post's creator.
Refactored getReplies() to implement shortcut.
Replaced method calls in viewThread template.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfBBPlugin/lib/model/sfBBPost.php

    r4015 r4016  
    1010class sfBBPost extends BasesfBBPost 
    1111{ 
     12  private 
     13    /** 
     14     * The post's creator. 
     15     * 
     16     * @var sfGuardUser 
     17     * @access private 
     18     */ 
     19    $user = null; 
     20 
    1221  public function setTitle($title) 
    1322  { 
     
    4554    $c->addJoin(sfGuardUserPeer::ID, sfBBPostPeer::USER_ID, Criteria::LEFT_JOIN); 
    4655    $c->addAscendingOrderByColumn(sfBBPostPeer::CREATED_AT); 
    47     return sfBBPostPeer::doSelectJoinsfGuardUser($c); 
     56    $replies = sfBBPostPeer::doSelectJoinsfGuardUser($c); 
     57 
     58    foreach ($replies as $reply) 
     59    { 
     60      $reply->setUser($reply->getsfGuardUser()); 
     61    } 
     62 
     63    return $replies; 
     64  } 
     65 
     66  /** 
     67   * Shortcut method to retrieve post's creator. 
     68   * 
     69   * @return sfGuardUser The post's creator. 
     70   */ 
     71  public function getUser() 
     72  { 
     73    if (!$this->user) 
     74    { 
     75      $c = new Criteria(); 
     76      $c->add(sfGuardUserPeer::ID, $this->getUserId()); 
     77      $this->user = sfGuardUserPeer::doSelectOne($c); 
     78    } 
     79 
     80    return $this->user; 
     81  } 
     82 
     83  public function setUser($user) 
     84  { 
     85    $this->user = $user; 
    4886  } 
    4987} 
  • plugins/sfBBPlugin/modules/sfBB/templates/viewThreadSuccess.php

    r4015 r4016  
    88    <tr> 
    99      <td> 
    10         <?php echo $thread->getsfGuardUser() ?> 
     10        <?php echo $thread->getUser() ?> 
    1111      </td> 
    1212      <td> 
     
    1919    <tr> 
    2020      <td> 
    21         <?php echo $reply->getsfGuardUser() ?> 
     21        <?php echo $reply->getUser() ?> 
    2222      </td> 
    2323      <td>