public function runAfterAuthentication(\User $objUser)
 {
     if (!ParticipationController::issetActiveParticipation()) {
         return false;
     }
     if ($this->maxParticipations > 0) {
         $intParticipations = ParticipationDataModel::countPublishedByPid($this->id);
         if ($intParticipations >= $this->maxParticipations) {
             ParticipationMessage::clearMessages();
             ParticipationMessage::addInfo(sprintf($GLOBALS['TL_LANG']['PARTICIPATION_MESSAGE']['maxParticipations'], ParticipationController::getParticipationLabel($this->getParticipation(), '', true)));
             // Remove active participation
             ParticipationController::removeActiveParticipation();
             return false;
         }
     }
     if ($this->maxParticipationsPerMember > 0) {
         $intParticipations = ParticipationDataModel::countPublishedBySourceIDAndTypesAndPid($objUser->id, array($this->targetType), $this->id);
         if ($intParticipations >= $this->maxParticipationsPerMember) {
             ParticipationMessage::clearMessages();
             ParticipationMessage::addDanger(sprintf($GLOBALS['TL_LANG']['PARTICIPATION_MESSAGE']['maxParticipationsPerMember'], ParticipationController::getParticipationLabel($this->getParticipation(), '', true)));
             // Remove active participation
             ParticipationController::removeActiveParticipation();
             return false;
         }
     }
     ParticipationMessage::clearMessages();
     $this->createNewData($objUser->id);
     ParticipationMessage::addSuccess(sprintf($GLOBALS['TL_LANG']['PARTICIPATION_MESSAGE']['newParticipationSuccess'], ParticipationController::getParticipationLabel($this->getParticipation(), '', true)));
     // remove participation from session
     ParticipationController::removeActiveParticipation();
 }
 protected function createNewData($sourceID)
 {
     $time = time();
     $objModel = new ParticipationDataModel();
     $objModel->pid = $this->objParticipation->id;
     $objModel->tstamp = $time;
     $objModel->createdOn = $time;
     $objModel->published = 1;
     $objModel->sourceID = $sourceID;
     $objModel->type = $this->objParticipation->targetType;
     $this->objModel = $objModel->save();
     // store this participation in recently added to prevent double submission
     ParticipationController::setRecentlyAddedParticipation($this->objParticipation->id);
 }
 public static function getRecentlyAddedParticipationData()
 {
     if (!isset($_SESSION[PARTICIPATION_RECENTLY_ADDED_SESSION_KEY])) {
         return null;
     }
     $strSessionKey = $_SESSION[PARTICIPATION_RECENTLY_ADDED_SESSION_KEY];
     return ParticipationDataModel::findPublishedByPid($strSessionKey);
 }