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

Changeset 10118


Ignore:
Timestamp:
Jan 13, 2009, 8:38:54 PM (11 years ago)
Author:
nagasawa
Message:

The newest information on a favorite diary is displayed

Location:
OpenPNE3/plugins/opFavoritePlugin/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opFavoritePlugin/trunk/apps/pc_frontend/modules/favorite/actions/actions.class.php

    r10055 r10118  
    2525  {
    2626    // id check
    27     if(!$this->hasRequestParameter('id')) $this->forward404Unless( NULL, 'Undefined id.');
     27    if (!$this->hasRequestParameter('id')) $this->forward404Unless( NULL, 'Undefined id.');
    2828    $this->id = $this->getRequestParameter('id', $this->getUser()->getMemberId());
     29
     30    $this->forward404Unless( $this->getUser()->getMemberId() != $this->id, 'Can\'t add your id' );
    2931
    3032    if ($this->id != $this->getUser()->getMemberId())
     
    4143  public function executeList($request)
    4244  {
    43     $this->pager = FavoritePeer::retrievePager($this->getUser()->getMemberId());
     45    $this->pager = FavoritePeer::retrievePager($this->getUser()->getMemberId(), $request->getParameter('id'));
    4446    $this->members = FavoritePeer::retrieveMembers($this->pager->getResults());
    4547    if (!$this->pager->getNbResults())
     
    4749      return sfView::ERROR;
    4850    }
     51  }
     52
     53/**
     54  * Executes diary blog list action
     55  *
     56  * @param sfRequest $request A request object
     57  */
     58  public function executeDiarybloglist($request)
     59  {
     60    $this->diaryPager = FavoritePeer::retrieveDiaryPager($this->getUser()->getMemberId(), $request->getParameter('id'));
     61    if (!$this->diaryPager->getNbResults())
     62    {
     63      return sfView::ERROR;
     64    }
     65    $this->diaryList = FavoritePeer::retrieveDiaryListFromPager($this->diaryPager);
    4966  }
    5067
  • OpenPNE3/plugins/opFavoritePlugin/trunk/apps/pc_frontend/modules/favorite/actions/components.class.php

    r10055 r10118  
    2121    $this->members = FavoritePeer::retrieveMembers($this->favorites);
    2222  }
     23  public function executeFavoriteNews()
     24  {
     25    $this->diary_list = FavoritePeer::retrieveDiaryList($this->getUser()->getMemberId());
     26  }
    2327}
  • OpenPNE3/plugins/opFavoritePlugin/trunk/config/widget.yml

    r10055 r10118  
    1212      IsRequired:  true
    1313      Default:     3
     14favoriteNews:
     15  component: [favorite, favoriteNews]
  • OpenPNE3/plugins/opFavoritePlugin/trunk/data/fixtures/020_widget.yml

    r10055 r10118  
    44    name: "favoriteListBox"
    55    sort_order: 40
    6 
     6  favorite_news:
     7    type: "contents"
     8    name: "favoriteNews"
     9    sort_order: 103
  • OpenPNE3/plugins/opFavoritePlugin/trunk/lib/model/FavoritePeer.php

    r10055 r10118  
    4242  {
    4343    $members = array();
    44     foreach($favorites as $favorite)
     44    foreach ($favorites as $favorite)
    4545    {
    4646      $members[] = MemberPeer::retrieveByPk($favorite->getTargetMemberId());
     
    7272  }
    7373
     74  public static function retrieveDiaryList($member_id, $size = 10)
     75  {
     76    $c = new Criteria();
     77    $c->add(FavoritePeer::MEMBER_ID, $member_id);
     78    $c->addJoin(FavoritePeer::TARGET_MEMBER_ID, MemberPeer::ID);
     79    $c->addJoin(FavoritePeer::TARGET_MEMBER_ID, DiaryPeer::MEMBER_ID);
     80    $c->addSelectColumn(MemberPeer::NAME);
     81    $c->addSelectColumn(DiaryPeer::TITLE);
     82    $c->addSelectColumn(DiaryPeer::CREATED_AT);
     83    $c->addSelectColumn(DiaryPeer::ID);
     84    $c->addSelectColumn(DiaryPeer::HAS_IMAGES);
     85    $c->addDescendingOrderbyColumn(DiaryPeer::ID);
     86    $c->setLimit($size);
    7487
     88    if (!FavoritePeer::doCount($c))
     89    {
     90      return null;
     91    }
     92
     93    $stmt = FavoritePeer::doSelectStmt($c);
     94
     95    $list = array();
     96    for ($i = 0; $row = $stmt->fetch(); $i++)
     97    {
     98      $list[$i] = array();
     99      $list[$i]['id'] = $row['ID'];
     100      $list[$i]['name'] = $row['NAME'];
     101      $list[$i]['title'] = $row['TITLE'];
     102      $list[$i]['date'] = $row['CREATED_AT'];
     103      $list[$i]['image'] = $row['HAS_IMAGES'];
     104    }
     105
     106    return $list;
     107  }
     108
     109  public static function retrieveDiaryPager($member_id, $page = 1, $size = 10)
     110  {
     111    $favorites = self::retrieveFavorites($member_id, $size);
     112    $c = new Criteria();
     113    foreach ($favorites as $favorite)
     114    {
     115      $c->add(DiaryPeer::MEMBER_ID, $favorite->getTargetMemberId());
     116    }
     117    $c->addDescendingOrderbyColumn(DiaryPeer::ID);
     118
     119    $pager = new sfPropelPager('Diary', $size);
     120    $pager->setCriteria($c);
     121    $pager->setPage($page);
     122    $pager->init();
     123
     124    return $pager;
     125  }
     126
     127  public static function retrieveDiaryListFromPager($pager)
     128  {
     129    $list = array();
     130    $i = 0;
     131    foreach($pager->getResults() as $diary)
     132    {
     133      $list[$i] = array();
     134      $list[$i]['id'] = $diary->getId();
     135      $list[$i]['name'] = MemberPeer::retrieveByPk($diary->getMemberId())->getName();
     136      $list[$i]['title'] = $diary->getTitle();
     137      $list[$i]['date'] = $diary->getCreatedAt();
     138      $list[$i]['image'] = $diary->getHasImages();
     139      $i++;
     140    }
     141
     142    return $list;
     143  }
    75144}
Note: See TracChangeset for help on using the changeset viewer.