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

Changeset 9032


Ignore:
Timestamp:
Nov 7, 2008, 5:38:51 PM (11 years ago)
Author:
ebihara
Message:

#3123:consolidated duplicated action methods to sfOpenPNECommunityAction

Location:
OpenPNE3/trunk
Files:
1 added
2 edited

Legend:

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

    r8878 r9032  
    77 * @subpackage community
    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 communityActions extends sfActions
     10class communityActions extends sfOpenPNECommunityAction
    1211{
    13   public function preExecute()
    14   {
    15     $this->id = $this->getRequestParameter('id');
    16 
    17     $this->isCommunityMember = CommunityMemberPeer::isMember($this->getUser()->getMemberId(), $this->id);
    18     $this->isAdmin = CommunityMemberPeer::isAdmin($this->getUser()->getMemberId(), $this->id);
    19     $this->isEditCommunity = $this->isAdmin;
    20   }
    21 
    22  /**
    23   * Executes home action
    24   *
    25   * @param sfRequest $request A request object
    26   */
    27   public function executeHome($request)
    28   {
    29     $this->community = CommunityPeer::retrieveByPk($this->id);
    30     $this->forward404Unless($this->community, 'Undefined community.');
    31   }
    32 
    33  /**
    34   * Executes joinlist action
    35   *
    36   * @param sfRequest $request A request object
    37   */
    38   public function executeJoinlist($request)
    39   {
    40     $memberId = $request->getParameter('member_id', $this->getUser()->getMemberId());
    41 
    42     $this->member = MemberPeer::retrieveByPK($memberId);
    43     $this->forward404Unless($this->member);
    44 
    45     $this->pager = CommunityPeer::getJoinCommunityListPager($memberId, $request->getParameter('page', 1));
    46 
    47     if (!$this->pager->getNbResults()) {
    48       return sfView::ERROR;
    49     }
    50 
    51     return sfView::SUCCESS;
    52   }
    53 
    54  /**
    55   * Executes edit action
    56   *
    57   * @param sfRequest $request A request object
    58   */
    59   public function executeEdit($request)
    60   {
    61     if ($this->id && !$this->isEditCommunity) {
    62       $this->forward('default', 'secure');
    63     }
    64 
    65     $this->community = CommunityPeer::retrieveByPk($this->id);
    66     $this->form = new CommunityForm($this->community);
    67 
    68     if ($request->isMethod('post')) {
    69       $this->form->bind($request->getParameter('community'));
    70       if ($this->form->isValid()) {
    71         $community = $this->form->save();
    72 
    73         $this->redirect('community/home?id=' . $community->getId());
    74       }
    75     }
    76   }
    77 
    78  /**
    79   * Executes join action
    80   *
    81   * @param sfRequest $request A request object
    82   */
    83   public function executeJoin($request)
    84   {
    85     if ($this->isCommunityMember) {
    86       return sfView::ERROR;
    87     }
    88 
    89     CommunityMemberPeer::join($this->getUser()->getMemberId(), $this->id);
    90     $this->redirect('community/home?id=' . $this->id);
    91   }
    92 
    93  /**
    94   * Executes quit action
    95   *
    96   * @param sfRequest $request A request object
    97   */
    98   public function executeQuit($request)
    99   {
    100     if (!$this->isCommunityMember || $this->isAdmin) {
    101       return sfView::ERROR;
    102     }
    103 
    104     CommunityMemberPeer::quit($this->getUser()->getMemberId(), $this->id);
    105     $this->redirect('community/home?id=' . $this->id);
    106   }
    107 
    108  /**
    109   * Executes memberList action
    110   *
    111   * @param sfRequest $request A request object
    112   */
    113   public function executeMemberList($request)
    114   {
    115     $this->community = CommunityPeer::retrieveByPk($this->id);
    116     $this->pager = CommunityPeer::getCommunityMemberListPager($this->id, $request->getParameter('page', 1));
    117 
    118     if (!$this->pager->getNbResults()) {
    119       return sfView::ERROR;
    120     }
    121 
    122     return sfView::SUCCESS;
    123   }
    12412}
  • OpenPNE3/trunk/apps/pc_frontend/modules/community/actions/actions.class.php

    r8567 r9032  
    77 * @subpackage community
    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 communityActions extends sfActions
     10class communityActions extends sfOpenPNECommunityAction
    1211{
    13   public function preExecute()
    14   {
    15     $this->id = $this->getRequestParameter('id');
    16 
    17     $this->isCommunityMember = CommunityMemberPeer::isMember($this->getUser()->getMemberId(), $this->id);
    18     $this->isAdmin = CommunityMemberPeer::isAdmin($this->getUser()->getMemberId(), $this->id);
    19     $this->isEditCommunity = $this->isAdmin;
    20   }
    21 
    22  /**
    23   * Executes index action
    24   *
    25   * @param sfRequest $request A request object
    26   */
    27   public function executeIndex($request)
    28   {
    29     $this->forward404();
    30   }
    31 
    3212 /**
    3313  * Executes edit action
     
    3717  public function executeEdit($request)
    3818  {
    39     if ($this->id && !$this->isEditCommunity) {
    40       $this->forward('default', 'secure');
    41     }
    42 
    43     $this->community = CommunityPeer::retrieveByPk($this->id);
    44     $this->form = new CommunityForm($this->community);
     19    $result = parent::executeEdit($request);
    4520
    4621    if (!$this->community) {
     
    4823    }
    4924
    50     if ($request->isMethod('post')) {
    51       $this->form->bind($request->getParameter('community'));
    52       if ($this->form->isValid()) {
    53         $community = $this->form->save();
    54 
    55         $this->redirect('community/home?id=' . $community->getId());
    56       }
    57     }
    58   }
    59 
    60  /**
    61   * Executes home action
    62   *
    63   * @param sfRequest $request A request object
    64   */
    65   public function executeHome($request)
    66   {
    67     $this->community = CommunityPeer::retrieveByPk($this->id);
    68     $this->forward404Unless($this->community, 'Undefined community.');
     25    return $result;
    6926  }
    7027
     
    8037    $this->pager->init();
    8138
    82     if (!$this->pager->getNbResults()) {
     39    if (!$this->pager->getNbResults())
     40    {
    8341      return sfView::ERROR;
    8442    }
     
    9452  public function executeJoinlist($request)
    9553  {
    96     $this->pager = CommunityPeer::getJoinCommunityListPager($request->getParameter('member_id', $this->getUser()->getMemberId()), $request->getParameter('page', 1));
     54    sfConfig::set('sf_navi_type', 'default');
    9755
    98     if (!$this->pager->getNbResults()) {
    99       return sfView::ERROR;
     56    if ($request->hasParameter('id') && $request->getParameter('id') != $this->getUser()->getMemberId())
     57    {
     58      sfConfig::set('sf_navi_type', 'friend');
    10059    }
    10160
    102     return sfView::SUCCESS;
     61    return parent::executeJoinlist($request);
    10362  }
    10463
    105  /**
    106   * Executes memberList action
    107   *
    108   * @param sfRequest $request A request object
    109   */
    110   public function executeMemberList($request)
    111   {
    112     $this->pager = CommunityPeer::getCommunityMemberListPager($this->id, $request->getParameter('page', 1));
    113 
    114     if (!$this->pager->getNbResults()) {
    115       return sfView::ERROR;
    116     }
    117 
    118     return sfView::SUCCESS;
    119   }
    120 
    121  /**
    122   * Executes join action
    123   *
    124   * @param sfRequest $request A request object
    125   */
    126   public function executeJoin($request)
    127   {
    128     if ($this->isCommunityMember) {
    129       return sfView::ERROR;
    130     }
    131 
    132     CommunityMemberPeer::join($this->getUser()->getMemberId(), $this->id);
    133     $this->redirect('community/home?id=' . $this->id);
    134   }
    135 
    136  /**
    137   * Executes quit action
    138   *
    139   * @param sfRequest $request A request object
    140   */
    141   public function executeQuit($request)
    142   {
    143     if (!$this->isCommunityMember || $this->isAdmin) {
    144       return sfView::ERROR;
    145     }
    146 
    147     CommunityMemberPeer::quit($this->getUser()->getMemberId(), $this->id);
    148     $this->redirect('community/home?id=' . $this->id);
    149   }
    15064}
Note: See TracChangeset for help on using the changeset viewer.