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

Changeset 10381


Ignore:
Timestamp:
Jan 25, 2009, 5:32:38 PM (14 years ago)
Author:
ebihara
Message:

#3376:added the communityTopicComment module

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

Legend:

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

    r10380 r10381  
    8080    }
    8181
    82     $this->commentPager = CommunityTopicCommentPeer::getCommunityTopicCommentListPager($this->communityTopic->getId(), $request->getParameter('page'), 20);
    83 
    8482    $this->form = new CommunityTopicCommentForm();
    8583  }
    86 /*
    87     if ($request->isMethod('post'))
    88     {
    89       $this->form->bind($request->getParameter('community_topic_comment'));
    90       if ($this->form->isValid())
    91       {
    92         $communityTopicComment = $this->form->save();
    93         $this->redirect('communityTopic/detail?id='.$this->communityTopicId);
    94       }
    95     }
    96     */
    9784
    9885 /**
     
    182169  }
    183170
     171 /**
     172  * Executes deleteConfirm action
     173  *
     174  * @param sfRequest $request A request object
     175  */
     176  public function executeDeleteConfirm(sfWebRequest $request)
     177  {
     178    $this->communityTopic = $this->getRoute()->getObject();
     179    $this->community = $this->communityTopic->getCommunity();
     180
     181    $this->forward404Unless(
     182         $this->community->isAdmin($this->getUser()->getMemberId())
     183      || $this->communityTopic->getMemberId() === $this->getUser()->getMemberId()
     184    );
     185
     186    $this->form = new sfForm();
     187  }
     188
     189 /**
     190  * Executes delete action
     191  *
     192  * @param sfRequest $request A request object
     193  */
     194  public function executeDelete(sfWebRequest $request)
     195  {
     196    $request->checkCSRFProtection();
     197
     198    $this->communityTopic = $this->getRoute()->getObject();
     199    $this->community = $this->communityTopic->getCommunity();
     200
     201    $this->forward404Unless(
     202         $this->community->isAdmin($this->getUser()->getMemberId())
     203      || $this->communityTopic->getMemberId() === $this->getUser()->getMemberId()
     204    );
     205
     206    $this->communityTopic->delete();
     207
     208    $this->getUser()->setFlash('notice', 'The community topic was deleted successfully.');
     209
     210    $this->redirect('community/home?id='.$this->community->getId());
     211  }
     212
    184213  protected function processForm(sfWebRequest $request, sfForm $form)
    185214  {
     
    195224    }
    196225  }
    197 
    198  /**
    199   * Executes deleteConfirm action
    200   *
    201   * @param sfRequest $request A request object
    202   */
    203   public function executeDeleteConfirm(sfWebRequest $request)
    204   {
    205     $this->communityTopic = $this->getRoute()->getObject();
    206     $this->community = $this->communityTopic->getCommunity();
    207 
    208     $this->forward404Unless(
    209          $this->community->isAdmin($this->getUser()->getMemberId())
    210       || $this->communityTopic->getMemberId() === $this->getUser()->getMemberId()
    211     );
    212 
    213     $this->form = new sfForm();
    214   }
    215 
    216  /**
    217   * Executes delete action
    218   *
    219   * @param sfRequest $request A request object
    220   */
    221   public function executeDelete(sfWebRequest $request)
    222   {
    223     $request->checkCSRFProtection();
    224 
    225     $this->communityTopic = $this->getRoute()->getObject();
    226     $this->community = $this->communityTopic->getCommunity();
    227 
    228     $this->forward404Unless(
    229          $this->community->isAdmin($this->getUser()->getMemberId())
    230       || $this->communityTopic->getMemberId() === $this->getUser()->getMemberId()
    231     );
    232 
    233     $this->communityTopic->delete();
    234 
    235     $this->getUser()->setFlash('notice', 'The community topic was deleted successfully.');
    236 
    237     $this->redirect('community/home?id='.$this->community->getId());
    238   }
    239226}
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/renewal/apps/pc_frontend/modules/communityTopic/templates/showSuccess.php

    r10377 r10381  
    2020</div>
    2121
    22 <?php if ($communityTopic->countCommunityTopicComments()) : ?>
    23 <div class="dparts commentList"><div class="parts">
    24 <div class="partsHeading">
    25 <h3><?php echo '書き込み' ?></h3>
    26 </div>
    27 
    28 <div class="pagerRelative"><p class="number"><?php echo pager_navigation($commentPager, 'communityTopic/detail?page=%d&id='.$communityTopic->getId()); ?></p></div>
    29 
    30 <table><tbody>
    31 <?php foreach ($commentPager->getResults() as $comment): ?>
    32 <tr>
    33 <th rowspan=2><?php echo format_datetime($comment->getUpdatedAt(), 'f'); ?></th>
    34 <td><?php echo $comment->getMember()->getName().' '.link_to('削除', 'comment/delete?id='.$communityTopic->getId().'&comment_id='.$comment->getId()) ?></td>
    35 </tr>
    36 <tr>
    37 <td class="border-left"><?php echo $comment->getBody() ?></td>
    38 </tr>
    39 <?php endforeach; ?>
    40 </tbody>
    41 </table>
    42 
    43 <div class="pagerRelative"><p class="number"><?php echo pager_navigation($commentPager, 'communityTopic/detail?page=%d&id='.$communityTopic->getId()); ?></p></div>
    44 
    45 </div>
    46 </div>
    47 <?php endif; ?>
     22<?php include_component('communityTopicComment', 'list', array('communityTopic' => $communityTopic)) ?>
    4823
    4924<?php
    50 $options = array(
    51   'form' => array($form),
    52   'button' => __('書き込み'),
    53 );
    54 $title = 'コメント書き込み';
    55 $options['url'] = 'communityTopic/detail?id='.$communityTopic->getId();
    56 include_box('formCommunityTopicComment', $title, '', $options);
     25$options = array();
     26$options['title'] = 'コメント書き込み';
     27$options['url'] = '@communityTopic_comment_create?id='.$communityTopic->getId();
     28op_include_form('formCommunityTopicComment', $form, $options);
    5729?>
    5830
  • OpenPNE3/plugins/opCommunityTopicPlugin/branches/renewal/lib/form/CommunityTopicCommentForm.class.php

    r10010 r10381  
    2121  public function configure()
    2222  {
    23     unset($this['created_at'], $this['updated_at']);
    24 
    25     $this->widgetSchema['community_topic_id'] = new sfWidgetFormInputHidden();
    26     $this->widgetSchema['member_id'] = new sfWidgetFormInputHidden();
    27     $this->setDefaults(array('community_topic_id' => $this->getOption('community_topic_id'), 'member_id' => sfContext::getInstance()->getUser()->getMemberId()));
     23    unset($this['id']);
     24    unset($this['community_topic_id']);
     25    unset($this['member_id']);
     26    unset($this['created_at']);
     27    unset($this['updated_at']);
    2828  }
    2929
Note: See TracChangeset for help on using the changeset viewer.