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

Changeset 10386


Ignore:
Timestamp:
Jan 25, 2009, 7:14:56 PM (14 years ago)
Author:
ebihara
Message:

#3372:unified the codes for checking a member has a privilege for editing a community topic

Location:
OpenPNE3/plugins/opCommunityTopicPlugin/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opCommunityTopicPlugin/trunk/apps/pc_frontend/modules/communityTopic/actions/actions.class.php

    r10384 r10386  
    2020class communityTopicActions extends sfActions
    2121{
    22   public function preExecute()
    23   {
    24     $this->communityTopicId = $this->getRequestParameter('id');
    25     $this->communityTopic = CommunityTopicPeer::retrieveByPk($this->communityTopicId);
    26 
    27     if ($this->communityTopic)
    28     {
    29       $this->community = $this->communityTopic->getCommunity();
    30     } else {
    31       $this->community = new Community();
    32       $this->community->setId($this->getRequestParameter('community_id'));
    33     }
    34     if ($this->community)
    35     {
    36     $this->communityId = $this->community->getId();
    37     }
    38 
    39     $this->communityConfigTopicAuthority = CommunityConfigPeer::retrieveByNameAndCommunityId('topic_authority', $this->communityId);
    40     if ($this->communityConfigTopicAuthority && $this->communityConfigTopicAuthority->getValue() === 'admin_only')
    41     {
    42       $this->checkOwner = true;
    43     }
    44     else
    45     {
    46       $this->checkOwner = false;
    47     }
    48   }
    49 
    5022 /**
    5123  * Executes listCommunity action
     
    140112    $this->community = $this->communityTopic->getCommunity();
    141113
    142     $this->forward404Unless(
    143          $this->community->isAdmin($this->getUser()->getMemberId())
    144       || $this->communityTopic->getMemberId() === $this->getUser()->getMemberId()
    145     );
     114    $this->forward404Unless($this->communityTopic->isEditable($this->getUser()->getMemberId()));
    146115
    147116    $this->form = new CommunityTopicForm($this->communityTopic);
     
    158127    $this->community = $this->communityTopic->getCommunity();
    159128
    160     $this->forward404Unless(
    161          $this->community->isAdmin($this->getUser()->getMemberId())
    162       || $this->communityTopic->getMemberId() === $this->getUser()->getMemberId()
    163     );
     129    $this->forward404Unless($this->communityTopic->isEditable($this->getUser()->getMemberId()));
    164130
    165131    $this->form = new CommunityTopicForm($this->communityTopic);
     
    179145    $this->community = $this->communityTopic->getCommunity();
    180146
    181     $this->forward404Unless(
    182          $this->community->isAdmin($this->getUser()->getMemberId())
    183       || $this->communityTopic->getMemberId() === $this->getUser()->getMemberId()
    184     );
     147    $this->forward404Unless($this->communityTopic->isEditable($this->getUser()->getMemberId()));
    185148
    186149    $this->form = new sfForm();
     
    199162    $this->community = $this->communityTopic->getCommunity();
    200163
    201     $this->forward404Unless(
    202          $this->community->isAdmin($this->getUser()->getMemberId())
    203       || $this->communityTopic->getMemberId() === $this->getUser()->getMemberId()
    204     );
     164    $this->forward404Unless($this->communityTopic->isEditable($this->getUser()->getMemberId()));
    205165
    206166    $this->communityTopic->delete();
  • OpenPNE3/plugins/opCommunityTopicPlugin/trunk/lib/model/CommunityTopic.php

    r10010 r10386  
    1111class CommunityTopic extends BaseCommunityTopic
    1212{
     13  public function isEditable($memberId)
     14  {
     15    return ($this->getMemberId() === $memberId || $this->getCommunity()->isAdmin($memberId));
     16  }
    1317}
  • OpenPNE3/plugins/opCommunityTopicPlugin/trunk/lib/model/CommunityTopicComment.php

    r10384 r10386  
    1313  public function isDeletable($memberId)
    1414  {
    15     if (
    16          $this->getCommunityTopic()->getCommunity()->isAdmin($memberId)
    17       || $this->getCommunityTopic()->getMemberId() === $memberId
    18       || $this->getMemberId() === $memberId
    19     )
    20     {
    21       return true;
    22     }
    23     else
    24     {
    25       return false;
    26     }
     15    return ($this->getMemberId() === $memberId || $this->getCommunityTopic()->isEditable($memberId));
    2716  }
    2817}
Note: See TracChangeset for help on using the changeset viewer.