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

Changeset 10382


Ignore:
Timestamp:
Jan 25, 2009, 6:02:51 PM (11 years ago)
Author:
ogawa
Message:

#3376:added ability to delete community topic comment

Location:
OpenPNE3/plugins/opCommunityTopicPlugin/branches/renewal
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/renewal/apps/pc_frontend/modules/communityTopicComment/actions/actions.class.php

    r10381 r10382  
    2929    $this->community = $this->communityTopic->getCommunity();
    3030
    31     if ($this->community->getConfig('public_flag') === 'auth_commu_member')
    32     {
    33       $this->forward404Unless($this->community->isPrivilegeBelong($this->getUser()->getMemberId()));
    34     }
     31    $this->forward404Unless($this->community->isPrivilegeBelong($this->getUser()->getMemberId()));
    3532
    3633    $this->form = new CommunityTopicCommentForm();
     
    4643    $this->setTemplate('../../communityTopic/templates/show');
    4744  }
     45
     46  public function executeDeleteConfirm(sfWebRequest $request)
     47  {
     48    $this->communityTopicComment = $this->getRoute()->getObject();
     49    $this->communityTopic = $this->communityTopicComment->getCommunityTopic();
     50    $this->community = $this->communityTopic->getCommunity();
     51
     52    $this->forward404Unless($this->communityTopicComment->isDeletable($this->getUser()->getMemberId()));
     53
     54    $this->form = new sfForm();
     55  }
     56
     57  public function executeDelete(sfWebRequest $request)
     58  {
     59    $request->checkCSRFProtection();
     60
     61    $this->communityTopicComment = $this->getRoute()->getObject();
     62    $this->communityTopic = $this->communityTopicComment->getCommunityTopic();
     63    $this->community = $this->communityTopic->getCommunity();
     64
     65    $this->forward404Unless($this->communityTopicComment->isDeletable($this->getUser()->getMemberId()));
     66
     67    $this->communityTopicComment->delete();
     68
     69    $this->getUser()->setFlash('notice', 'The comment was deleted successfully.');
     70
     71    $this->redirect($this->generateUrl('communityTopic_show', $this->communityTopic));
     72  }
    4873}
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/renewal/apps/pc_frontend/modules/communityTopicComment/templates/_list.php

    r10381 r10382  
    1111<tr>
    1212<th rowspan=2><?php echo format_datetime($comment->getUpdatedAt(), 'f'); ?></th>
    13 <td><?php echo $comment->getMember()->getName().' '.link_to('削除', 'comment/delete?id='.$communityTopic->getId().'&comment_id='.$comment->getId()) ?></td>
     13<td><?php echo $comment->getMember()->getName() ?><?php if ($comment->isDeletable($sf_user->getMemberId())): ?> <?php echo link_to(__('Delete'), '@communityTopic_comment_delete_confirm?id='.$comment->getId()) ?><?php endif; ?></td>
    1414</tr>
    1515<tr>
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/renewal/lib/model/CommunityTopicComment.php

    r10010 r10382  
    1111class CommunityTopicComment extends BaseCommunityTopicComment
    1212{
     13  public function isDeletable($memberId)
     14  {
     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    }
     27  }
    1328}
Note: See TracChangeset for help on using the changeset viewer.