ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 9860


Ignore:
Timestamp:
Jan 3, 2009, 5:20:42 PM (11 years ago)
Author:
ogawa
Message:

#3209:removed duplicate code in opDiaryPluginDiaryActions and opDiaryPluginDiaryCommentActions

Location:
OpenPNE3/plugins/opDiaryPlugin/trunk/lib/action
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/action/opDiaryPluginDiaryActions.class.php

    r9859 r9860  
    88 * @author     Rimpei Ogawa <ogawa@tejimaya.com>
    99 */
    10 class opDiaryPluginDiaryActions extends sfActions
     10class opDiaryPluginDiaryActions extends opDiaryPluginActions
    1111{
    12   public function preExecute()
    13   {
    14     if (is_callable(array($this->getRoute(), 'getObject')))
    15     {
    16       $object = $this->getRoute()->getObject();
    17       if ($object instanceof Diary)
    18       {
    19         $this->diary = $object;
    20         $this->setNavigation($this->diary->getMemberId());
    21       }
    22       elseif ($object instanceof Member)
    23       {
    24         $this->member = $object;
    25         $this->setNavigation($this->member->getId());
    26       }
    27     }
    28   }
    29 
    30   protected function setNavigation($memberId)
    31   {
    32     if ($memberId !== $this->getUser()->getMemberId())
    33     {
    34       sfConfig::set('sf_navi_type', 'friend');
    35       sfConfig::set('sf_navi_id', $memberId);
    36     }
    37   }
    38 
    3912  public function executeIndex(sfWebRequest $request)
    4013  {
     
    11689    }
    11790  }
    118 
    119   protected function isAuthor()
    120   {
    121     if ($this->diary->getMemberId() === $this->getUser()->getMemberId())
    122     {
    123       return true;
    124     }
    125 
    126     return false;
    127   }
    128 
    129   protected function isViewable()
    130   {
    131     return DiaryPeer::isViewable($this->diary, $this->getUser()->getMemberId());
    132   }
    13391}
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/action/opDiaryPluginDiaryCommentActions.class.php

    r9859 r9860  
    88 * @author     Rimpei Ogawa <ogawa@tejimaya.com>
    99 */
    10 class opDiaryPluginDiaryCommentActions extends sfActions
     10class opDiaryPluginDiaryCommentActions extends opDiaryPluginActions
    1111{
    12   public function preExecute()
    13   {
    14     if (is_callable(array($this->getRoute(), 'getObject')))
    15     {
    16       $object = $this->getRoute()->getObject();
    17       if ($object instanceof Diary)
    18       {
    19         $this->diary = $object;
    20         $this->setNavigation($this->diary->getMemberId());
    21       }
    22       elseif ($object instanceof DiaryComment)
    23       {
    24         $this->diaryComment = $object;
    25         $this->diary = $this->diaryComment->getDiary();
    26         $this->setNavigation($this->diary->getMemberId());
    27       }
    28     }
    29   }
    30 
    31   protected function setNavigation($memberId)
    32   {
    33     if ($memberId !== $this->getUser()->getMemberId())
    34     {
    35       sfConfig::set('sf_navi_type', 'friend');
    36       sfConfig::set('sf_navi_id', $memberId);
    37     }
    38   }
    39 
    4012  public function executeCreate(sfWebRequest $request)
    4113  {
     
    7244    $this->redirect($this->generateUrl('diary_show', $this->diary));
    7345  }
    74 
    75   protected function isAuthor()
    76   {
    77     if ($this->diary->getMemberId() === $this->getUser()->getMemberId())
    78     {
    79       return true;
    80     }
    81 
    82     return false;
    83   }
    84 
    85   protected function isViewable()
    86   {
    87     return DiaryPeer::isViewable($this->diary, $this->getUser()->getMemberId());
    88   }
    8946}
Note: See TracChangeset for help on using the changeset viewer.