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

Changeset 11170


Ignore:
Timestamp:
Mar 26, 2009, 12:34:49 AM (13 years ago)
Author:
ebihara
Message:

#3672:added some limitation checks when a member tries to participate in an event

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

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opCommunityTopicPlugin/trunk/apps/pc_frontend/i18n/messages.ja.xml

    r11155 r11170  
    103103        <target>本当にこのイベントを削除しますか?</target>
    104104      </trans-unit>
     105      <trans-unit id="">
     106        <source>This event has already been finished.</source>
     107        <target>このイベントは既に終了しています。</target>
     108      </trans-unit>
     109      <trans-unit id="">
     110        <source>This event has already been expired.</source>
     111        <target>このイベントは募集期日が切れています。</target>
     112      </trans-unit>
     113      <trans-unit id="">
     114        <source>This event has already been at capacity.</source>
     115        <target>このイベントは定員に達しています。</target>
     116      </trans-unit>
    105117    </body>
    106118  </file>
  • OpenPNE3/plugins/opCommunityTopicPlugin/trunk/lib/action/opCommunityTopicPluginEventCommentActions.class.php

    r11155 r11170  
    5353    if ($this->form->isValid())
    5454    {
    55       if (!$request->getParameter('comment'))
     55      try
    5656      {
    57         $this->form->getObject()->toggleEventMember($this->getUser()->getMemberId());
     57        if (!$request->getParameter('comment'))
     58        {
     59          $this->form->getObject()->toggleEventMember($this->getUser()->getMemberId());
     60        }
     61
     62        $this->form->save();
     63        $this->redirect('@communityEvent_show?id='.$this->communityEvent->getId());
    5864      }
    59       $this->form->save();
    60 
    61       $this->redirect('@communityEvent_show?id='.$this->communityEvent->getId());
     65      catch (opCommunityEventMemberAppendableException $e)
     66      {
     67        $this->getUser()->setFlash('error', $e->getMessage());
     68      }
    6269    }
    6370
  • OpenPNE3/plugins/opCommunityTopicPlugin/trunk/lib/model/CommunityEvent.php

    r11155 r11170  
    5151  public function toggleEventMember($memberId)
    5252  {
     53    if ($this->isClosed())
     54    {
     55      throw new opCommunityEventMemberAppendableException('This event has already been finished.');
     56    }
     57
     58    if ($this->isExpired())
     59    {
     60      throw new opCommunityEventMemberAppendableException('This event has already been expired.');
     61    }
     62
    5363    if ($this->isEventMember($memberId))
    5464    {
     
    5868    else
    5969    {
     70      if ($this->isAtCapacity())
     71      {
     72        throw new opCommunityEventMemberAppendableException('This event has already been at capacity.');
     73      }
     74
    6075      $eventMember = new CommunityEventMember();
    6176      $eventMember->setCommunityEventId($this->getId());
     
    6580    }
    6681  }
     82
     83  public function isClosed()
     84  {
     85    return (time() > $this->getOpenDate('U'));
     86  }
     87
     88  public function isExpired()
     89  {
     90    return (!is_null($this->getApplicationDeadline()) && time() > $this->getApplicationDeadline('U'));
     91  }
     92
     93  public function isAtCapacity()
     94  {
     95    return (!is_null($this->getCapacity()) && $this->countCommunityEventMembers() >= $this->getCapacity());
     96  }
    6797}
Note: See TracChangeset for help on using the changeset viewer.