public function listenToPostActionEventCommunityJoin($arguments)
 {
     $memberId = sfContext::getInstance()->getUser()->getMemberId();
     $communityId = $arguments['actionInstance']->getVar('id');
     $communityMember = Doctrine::getTable('CommunityMember')->retrieveByMemberIdAndCommunityId($memberId, $communityId);
     if (!$communityMember) {
         $communityMember = new CommunityMember();
         $communityMember->setCommunityId($communityId);
         $communityMember->setMemberId($memberId);
         $communityMember->setIsPre(true);
     }
     if ($communityMember->getIsPre()) {
         $isInvited = opCommunityIntroductionPlugin::isInvitedCommunity($communityId, $memberId);
         if ($isInvited) {
             $communityMember->setIsPre(false);
             $communityMember->save();
             sfContext::getInstance()->getUser()->setFlash('notice', 'You have just joined to this %community%.');
             sfContext::getInstance()->getController()->redirect('community/home?id=' . $communityId);
         }
     }
 }
 public function join($memberId, $communityId, $isRegisterPolicy = 'open')
 {
     if ($this->isPreMember($memberId, $communityId)) {
         throw new Exception('This member has already applied this community.');
     }
     if ($this->isMember($memberId, $communityId)) {
         throw new Exception('This member has already joined this community.');
     }
     $communityMember = new CommunityMember();
     $communityMember->setMemberId($memberId);
     $communityMember->setCommunityId($communityId);
     if ($isRegisterPolicy == 'close') {
         $communityMember->setIsPre(true);
     }
     $communityMember->save();
 }