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

Changeset 9033


Ignore:
Timestamp:
Nov 7, 2008, 6:09:39 PM (11 years ago)
Author:
ebihara
Message:

#3123:consolidated duplicated action methods to sfOpenPNEFriendAction

Location:
OpenPNE3/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/apps/mobile_frontend/modules/friend/actions/actions.class.php

    r8969 r9033  
    77 * @subpackage friend
    88 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
    9  * @version    SVN: $Id: actions.class.php 9301 2008-05-27 01:08:46Z dwhittle $
    109 */
    11 class friendActions extends sfActions
     10class friendActions extends sfOpenPNEFriendAction
    1211{
    13   public function preExecute()
    14   {
    15     $this->id = $this->getRequestParameter('id', $this->getUser()->getMemberId());
    16     $this->isFriend = FriendPeer::isFriend($this->getUser()->getMemberId(), $this->id);
    17     $this->isFriendPre = FriendPrePeer::isFriendPre($this->getUser()->getMemberId(), $this->id);
    18   }
    19 
    20  /**
    21   * Executes list action
    22   *
    23   * @param sfRequest $request A request object
    24   */
    25   public function executeList($request)
    26   {
    27     $this->pager = FriendPeer::getFriendListPager($this->id, $request->getParameter('page', 1));
    28 
    29     if (!$this->pager->getNbResults()) {
    30       return sfView::ERROR;
    31     }
    32 
    33     return sfView::SUCCESS;
    34   }
    35 
    36  /**
    37   * Executes link action
    38   *
    39   * @param sfRequest $request A request object
    40   */
    41   public function executeLink($request)
    42   {
    43     if ($this->isFriend)
    44     {
    45       return sfView::ERROR;
    46     }
    47 
    48     if ($this->isFriendPre)
    49     {
    50       return sfView::ERROR;
    51     }
    52 
    53     $this->redirectToHomeIfIdIsNotValid();
    54 
    55     $friendPre = new FriendPre();
    56     $friendPre->setMemberIdFrom($this->getUser()->getMemberId());
    57     $friendPre->setMemberIdTo($this->id);
    58     $friendPre->save();
    59 
    60     $this->redirect('member/profile?id='.$this->id);
    61   }
    62 
    63  /**
    64   * Executes linkAccept action
    65   *
    66   * @param sfRequest $request A request object
    67   */
    68   public function executeLinkAccept($request)
    69   {
    70     if (!$this->isFriendPre) {
    71       return sfView::ERROR;
    72     }
    73 
    74     $this->redirectToHomeIfIdIsNotValid();
    75 
    76     $friendPre = FriendPrePeer::retrieveByMemberIdToAndMemberIdFrom($this->getUser()->getMemberId(), $this->id);
    77     $this->forward404Unless($friendPre);
    78 
    79     FriendPeer::link($friendPre->getMemberIdTo(), $friendPre->getMemberIdFrom());
    80     $friendPre->delete();
    81 
    82     $this->redirect('member/profile?id=' . $this->id);
    83   }
    84 
    85  /**
    86   * Executes linkReject action
    87   *
    88   * @param sfRequest $request A request object
    89   */
    90   public function executeLinkReject($request)
    91   {
    92     if (!$this->isFriendPre) {
    93       return sfView::ERROR;
    94     }
    95 
    96     $this->redirectToHomeIfIdIsNotValid();
    97 
    98     $friendPre = FriendPrePeer::retrieveByMemberIdToAndMemberIdFrom($this->getUser()->getMemberId(), $this->id);
    99     $this->forward404Unless($friendPre);
    100 
    101     $friendPre->delete();
    102 
    103     $this->redirect('@homepage');
    104   }
    105 
    106  /**
    107   * Redirects to your home if ID is yours or it is empty.
    108   */
    109   private function redirectToHomeIfIdIsNotValid()
    110   {
    111     $this->redirectUnless($this->id, 'member/home');
    112     $this->redirectIf(($this->id == $this->getUser()->getMemberId()), 'member/home');
    113   }
    11412}
  • OpenPNE3/trunk/apps/pc_frontend/modules/friend/actions/actions.class.php

    r8950 r9033  
    77 * @subpackage friend
    88 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
    9  * @version    SVN: $Id: actions.class.php 9301 2008-05-27 01:08:46Z dwhittle $
    109 */
    11 class friendActions extends sfActions
     10class friendActions extends sfOpenPNEFriendAction
    1211{
    1312  public function preExecute()
    1413  {
    15     $this->id = $this->getRequestParameter('id', $this->getUser()->getMemberId());
    16     $this->isFriend = FriendPeer::isFriend($this->getUser()->getMemberId(), $this->id);
    17     $this->isFriendPre = FriendPrePeer::isFriendPre($this->getUser()->getMemberId(), $this->id);
    18     if ($this->id == $this->getUser()->getMemberId()) {
     14    parent::preExecute();
     15
     16    if ($this->id == $this->getUser()->getMemberId())
     17    {
    1918      sfConfig::set('sf_navi_type', 'default');
    2019    }
    2120  }
    22 
    23  /**
    24   * Executes index action
    25   *
    26   * @param sfRequest $request A request object
    27   */
    28   public function executeIndex($request)
    29   {
    30     $this->forward('default', 'module');
    31   }
    32 
    33  /**
    34   * Executes list action
    35   *
    36   * @param sfRequest $request A request object
    37   */
    38   public function executeList($request)
    39   {
    40     $this->pager = FriendPeer::getFriendListPager($this->id, $request->getParameter('page', 1));
    41 
    42     if (!$this->pager->getNbResults()) {
    43       return sfView::ERROR;
    44     }
    45 
    46     return sfView::SUCCESS;
    47   }
    48 
    49  /**
    50   * Executes link action
    51   *
    52   * @param sfRequest $request A request object
    53   */
    54   public function executeLink($request)
    55   {
    56     if ($this->isFriend) {
    57       return sfView::ERROR;
    58     }
    59 
    60     if ($this->isFriendPre) {
    61       return sfView::ERROR;
    62     }
    63 
    64     $this->redirectToHomeIfIdIsNotValid();
    65 
    66     $friendPre = new FriendPre();
    67     $friendPre->setMemberIdFrom($this->getUser()->getMemberId());
    68     $friendPre->setMemberIdTo($this->id);
    69     $friendPre->save();
    70 
    71     $this->redirect('member/profile?id=' . $this->id);
    72   }
    73 
    74  /**
    75   * Executes linkAccept action
    76   *
    77   * @param sfRequest $request A request object
    78   */
    79   public function executeLinkAccept($request)
    80   {
    81     if (!$this->isFriendPre) {
    82       return sfView::ERROR;
    83     }
    84 
    85     $this->redirectToHomeIfIdIsNotValid();
    86 
    87     $friendPre = FriendPrePeer::retrieveByMemberIdToAndMemberIdFrom($this->getUser()->getMemberId(), $this->id);
    88     $this->forward404Unless($friendPre);
    89 
    90     FriendPeer::link($friendPre->getMemberIdTo(), $friendPre->getMemberIdFrom());
    91     $friendPre->delete();
    92 
    93     $this->redirect('member/profile?id=' . $this->id);
    94   }
    95 
    96  /**
    97   * Executes linkReject action
    98   *
    99   * @param sfRequest $request A request object
    100   */
    101   public function executeLinkReject($request)
    102   {
    103     if (!$this->isFriendPre) {
    104       return sfView::ERROR;
    105     }
    106 
    107     $this->redirectToHomeIfIdIsNotValid();
    108 
    109     $friendPre = FriendPrePeer::retrieveByMemberIdToAndMemberIdFrom($this->getUser()->getMemberId(), $this->id);
    110     $this->forward404Unless($friendPre);
    111 
    112     $friendPre->delete();
    113 
    114     $this->redirect('@homepage');
    115   }
    116 
    117  /**
    118   * Executes unlink action
    119   *
    120   * @param sfRequest $request A request object
    121   */
    122   public function executeUnlink($request)
    123   {
    124     if (!$this->isFriend) {
    125       return sfView::ERROR;
    126     }
    127     $this->redirectToHomeIfIdIsNotValid();
    128     FriendPeer::unlink($this->getUser()->getMemberId(), $this->id);
    129     $this->redirect('member/profile?id=' . $this->id);
    130   }
    131 
    132  /**
    133   * Redirects to your home if ID is yours or it is empty.
    134   */
    135   private function redirectToHomeIfIdIsNotValid()
    136   {
    137     $this->redirectUnless($this->id, 'member/home');
    138     $this->redirectIf(($this->id == $this->getUser()->getMemberId()), 'member/home');
    139   }
    14021}
Note: See TracChangeset for help on using the changeset viewer.