Skip to content

Commit

Permalink
アクセスブロックを考慮していなかったのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
Masato Nagasawa committed May 27, 2011
1 parent 2ea5f2d commit b4d4c67
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
Expand Up @@ -25,8 +25,8 @@ class favoriteActions extends opFavoritePluginFavoriteActions
*/
public function executeAdd($request)
{
parent::executeAdd($request);
$request->checkCSRFProtection();
$this->idCheck();
Doctrine::getTable('Favorite')->add($this->getUser()->getMemberId(), $this->id);
$this->redirect('favorite/list');
}
Expand Down
Expand Up @@ -24,7 +24,7 @@ class favoriteActions extends opFavoritePluginFavoriteActions
*/
public function executeAdd($request)
{
$this->idCheck();
parent::executeAdd($request);
$favoriteTable = Doctrine::getTable('Favorite');
if ($request->isMethod('post'))
{
Expand Down
19 changes: 18 additions & 1 deletion lib/action/opFavoritePluginFavoriteActions.class.php
Expand Up @@ -34,6 +34,23 @@ public function idCheck()
}
}

/**
* Executes add action
*
* @param sfRequest $request A request object
*/
public function executeAdd($request)
{
$this->idCheck();

$relation = Doctrine::getTable('MemberRelationship')
->retrieveByFromAndTo($this->id, $this->getUser()->getMemberId());
if ($relation)
{
$this->forward404If($relation->getIsAccessBlock());
}
}

/**
* Executes list action
*
Expand Down Expand Up @@ -72,7 +89,7 @@ public function executeDiary($request)
$this->pager = Doctrine::getTable('Favorite')->retrieveDiaryPager($this->getUser()->getMemberId(), $request->getParameter('page', 1));
if (!$this->pager->getNbResults())
{
return sfView::ERROR;
return sfView::ALERT;
}
}
}
16 changes: 12 additions & 4 deletions lib/model/doctrine/PluginFavoriteTable.class.php
Expand Up @@ -78,7 +78,7 @@ public function retrieveDiaryList($member_id_from, $size = 10)
}

$q = Doctrine::getTable('Diary')->createQuery()
->whereIn('member_id', $this->getFavoriteToIds($member_id_from));
->whereIn('member_id', $this->getShowMemberIds($member_id_from));
Doctrine::getTable('Diary')->addPublicFlagQuery($q, DiaryTable::PUBLIC_FLAG_SNS);
$q->orderBy('created_at DESC')
->limit($size);
Expand All @@ -94,7 +94,7 @@ public function retrieveDiaryPager($member_id_from, $page = 1, $size = 10)
}

$q = Doctrine::getTable('Diary')->createQuery()
->whereIn('member_id', $this->getFavoriteToIds($member_id_from));
->whereIn('member_id', $this->getShowMemberIds($member_id_from));
Doctrine::getTable('Diary')->addPublicFlagQuery($q, DiaryTable::PUBLIC_FLAG_SNS);
$q->orderBy('created_at DESC')
->limit($size);
Expand Down Expand Up @@ -140,15 +140,15 @@ public function setDiary($date, $title, $id, $name, $image)
);
}

public function getBlogListOfFavorite($member_id_from, $size=20, $limitTitle = false)
public function getBlogListOfFavorite($memberId, $size=20, $limitTitle = false)
{
if (!class_exists('opBlogPlugin'))
{
return array();
}

$list = Doctrine::getTable('BlogRssCache')->createQuery()
->whereIn('member_id', $this->getFavoriteToIds($member_id_from))
->whereIn('member_id', $this->getShowMemberIds($memberId))
->orderBy('date DESC')
->limit($size)
->execute();
Expand Down Expand Up @@ -177,6 +177,14 @@ public function getFavoriteToIds($member_id_from)
return $memberIds;
}

public function getShowMemberIds($memberId)
{
$memberIds = $this->getFavoriteToIds($memberId);
$blockedMemberIds = Doctrine::getTable('MemberRelationship')->getBlockedMemberIdsByTo($memberId);

return array_diff($memberIds, $blockedMemberIds);
}

public function retrieveByMemberIdFromAndTo($member_id_from, $member_id_to)
{
$q = $this->createQuery()
Expand Down

0 comments on commit b4d4c67

Please sign in to comment.