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

source: OpenPNE3/plugins/opCommunityTopicPlugin/trunk/lib/model/CommunityEvent.php @ 11155

Last change on this file since 11155 was 11155, checked in by ebihara, 13 years ago

#3672:added ability to handle community event members

File size: 1.7 KB
Line 
1<?php
2
3/**
4 * This file is part of the OpenPNE package.
5 * (c) OpenPNE Project (http://www.openpne.jp/)
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file and the NOTICE file that were distributed with this source code.
9 */
10
11class CommunityEvent extends BaseCommunityEvent
12{
13  public function isEditable($memberId)
14  {
15    if (!$this->getCommunity()->isPrivilegeBelong($memberId))
16    {
17      return false;
18    }
19
20    return ($this->getMemberId() === $memberId || $this->getCommunity()->isAdmin($memberId));
21  }
22
23  public function isCreatableCommunityEventComment($memberId)
24  {
25    return $this->getCommunity()->isPrivilegeBelong($memberId);
26  }
27
28  public function isEventMember($memberId)
29  {
30    return (bool)CommunityEventMemberPeer::retrieveByEventIdAndMemberId($this->getId(), $memberId);
31  }
32
33  public function isEventModified()
34  {
35    return (
36      $this->isColumnModified(CommunityEventPeer::NAME) ||
37      $this->isColumnModified(CommunityEventPeer::BODY)
38    );
39  }
40
41  public function save(PropelPDO $con = null)
42  {
43    if ($this->isEventModified() && !$this->isColumnModified(CommunityEventPeer::EVENT_UPDATED_AT))
44    {
45      $this->setEventUpdatedAt(time());
46    }
47   
48    parent::save($con);
49  }
50
51  public function toggleEventMember($memberId)
52  {
53    if ($this->isEventMember($memberId))
54    {
55      $eventMember = CommunityEventMemberPeer::retrieveByEventIdAndMemberId($this->getId(), $memberId);
56      $eventMember->delete();
57    }
58    else
59    {
60      $eventMember = new CommunityEventMember();
61      $eventMember->setCommunityEventId($this->getId());
62      $eventMember->setMemberId($memberId);
63
64      $this->addCommunityEventMember($eventMember);
65    }
66  }
67}
Note: See TracBrowser for help on using the repository browser.