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

Changeset 9551


Ignore:
Timestamp:
Dec 13, 2008, 4:41:25 PM (11 years ago)
Author:
ogawa
Message:

#3209:created three list pages; list, listMember and listFriend

Location:
OpenPNE3/plugins/opDiaryPlugin/trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/actions/actions.class.php

    r9527 r9551  
    2727  public function executeList($request)
    2828  {
    29     $this->pager = DiaryPeer::retrieveDiaryPager($request->getParameter('page'), 20);
     29    $this->pager = DiaryPeer::getDiaryPager($request->getParameter('page'), 20);
     30  }
     31
     32 /**
     33  * Executes listMember action
     34  *
     35  * @param sfRequest $request A request object
     36  */
     37  public function executeListMember($request)
     38  {
     39    $memberId = $request->getParameter('id', $this->getUser()->getMemberId());
     40    $this->member = MemberPeer::retrieveByPk($memberId);
     41    $this->forward404unless($this->member);
     42
     43    $this->pager = DiaryPeer::getMemberDiaryPager($memberId, $request->getParameter('page'), 20);
     44
     45    if ($memberId !== $this->getUser()->getMemberId())
     46    {
     47      sfConfig::set('sf_navi_type', 'friend');
     48      sfConfig::set('sf_navi_id', $memberId);
     49    }
     50  }
     51
     52 /**
     53  * Executes listFriend action
     54  *
     55  * @param sfRequest $request A request object
     56  */
     57  public function executeListFriend($request)
     58  {
     59    $this->pager = DiaryPeer::getFriendDiaryPager($this->getUser()->getMemberId(), $request->getParameter('page'), 20);
    3060  }
    3161
     
    3868  {
    3969    $this->diary = DiaryPeer::retrieveByPk($request->getParameter('id'));
    40     $this->forward404Unless($this->diary);
     70    $this->forward404unless($this->diary);
     71    if ($this->diary->getMemberId() !== $this->getUser()->getMemberId())
     72    {
     73      sfConfig::set('sf_navi_type', 'friend');
     74      sfConfig::set('sf_navi_id', $this->diary->getMemberId());
     75    }
    4176  }
    4277
     
    4984  {
    5085    $this->diary = DiaryPeer::retrieveByPk($request->getParameter('id'));
     86    if ($this->diary)
     87    {
     88      $this->forward404Unless($this->diary->getMemberId() === $this->getUser()->getMemberId());
     89    }
    5190    $this->form = new DiaryForm($this->diary);
    5291
     
    74113    $diary = DiaryPeer::retrieveByPk($request->getParameter('id'));
    75114    $this->forward404Unless($diary);
    76     $this->redirectUnless($diary->getMemberId() === $this->getUser()->getMemberId(), '@homepage');
     115    $this->forward404Unless($diary->getMemberId() === $this->getUser()->getMemberId());
    77116
    78117    $diary->delete();
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/actions/components.class.php

    r9543 r9551  
    1212  public function executeMyDiaryList()
    1313  {
    14     $this->diaryList = DiaryPeer::retrieveByMemberId($this->getUser()->getMemberId(), 5);
     14    $this->diaryList = DiaryPeer::getMemberDiaryList($this->getUser()->getMemberId(), 5);
    1515  }
    1616
     
    1919    $this->diaryList = DiaryPeer::getFriendDiaryList($this->getUser()->getMemberId(), 5);
    2020  }
     21
     22  public function executeMemberDiaryList($request)
     23  {
     24    $this->memberId = $request->getParameter('id', $this->getUser()->getMemberId());
     25    $this->diaryList = DiaryPeer::getMemberDiaryList($this->memberId, 5);
     26  }
    2127}
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/_friendDiaryList.php

    r9550 r9551  
    99<?php endforeach; ?>
    1010</ul>
     11<?php echo link_to('もっと見る', 'diary/listFriend') ?>
    1112</div></div>
    1213</div></div>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/_myDiaryList.php

    r9550 r9551  
    99<?php endforeach; ?>
    1010</ul>
     11<p><?php echo link_to('もっと見る', 'diary/listMember') ?></p>
    1112<p><?php echo link_to('日記を書く', 'diary/edit') ?></p>
    1213</div></div>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/member/config/view.yml

    r9543 r9551  
    77      parts:    [homeTopSampleBox]
    88      target:   [after]
     9profileSuccess:
     10  customize:
     11    memberDiaryList:
     12      parts:    [profile]
     13      target:   [after]
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/model/DiaryPeer.php

    r9543 r9551  
    33class DiaryPeer extends BaseDiaryPeer
    44{
    5   public static function retrieveByMemberId($memberId, $limit = 5)
     5  public static function getDiaryPager($page = 1, $size = 20)
     6  {
     7    $c = new Criteria();
     8    $c->addDescendingOrderByColumn(self::CREATED_AT);
     9
     10    $pager = new sfPropelPager('Diary', $size);
     11    $pager->setCriteria($c);
     12    $pager->setPage($page);
     13    $pager->init();
     14
     15    return $pager;
     16  }
     17
     18  public static function getMemberDiaryList($memberId, $limit = 5)
    619  {
    720    $c = new Criteria();
     
    1225  }
    1326
    14   public static function retrieveDiaryPager($page = 1, $size = 20)
     27  public static function getMemberDiaryPager($memberId, $page = 1, $size = 20)
    1528  {
    1629    $c = new Criteria();
     30    $c->add(self::MEMBER_ID, $memberId);
    1731    $c->addDescendingOrderByColumn(self::CREATED_AT);
    1832
     
    3549    return self::doSelect($c);
    3650  }
     51
     52  public static function getFriendDiaryPager($memberId, $page = 1, $size = 20)
     53  {
     54    $friendIds = MemberRelationshipPeer::getFriendMemberIds($memberId, 5);
     55
     56    $c = new Criteria();
     57    $c->add(self::MEMBER_ID, $friendIds, Criteria::IN);
     58    $c->addDescendingOrderByColumn(self::CREATED_AT);
     59
     60    $pager = new sfPropelPager('Diary', $size);
     61    $pager->setCriteria($c);
     62    $pager->setPage($page);
     63    $pager->init();
     64
     65    return $pager;
     66  }
    3767}
Note: See TracChangeset for help on using the changeset viewer.