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();
 }
コード例 #2
0
 public function processMemberParticipation($objUser)
 {
     if (TL_MODE != 'FE') {
         return false;
     }
     $objParticipation = ParticipationController::getActiveParticipation();
     if ($objParticipation === null) {
         return false;
     }
     if (($objConfig = ParticipationController::findParticipationDataConfigClass($objParticipation)) !== null) {
         global $objPage;
         $objJumpTo = $objConfig->getJumpToPage();
         // redirect first, otherwise participation process will run twice
         if ($objJumpTo !== null && $objPage->id != $objJumpTo->id) {
             \Controller::redirect(\Controller::generateFrontendUrl($objJumpTo->row()));
         }
         $objConfig->runAfterAuthentication($objUser);
         return true;
     }
 }
コード例 #3
0
 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);
 }