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();
 }
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD'][$this->type][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     if (!ParticipationMessage::hasMessages()) {
         return '';
     }
     return parent::generate();
 }
Ejemplo n.º 3
0
 public static function getPageIdFromUrlHook($arrFragments)
 {
     $objParticipation = ParticipationModel::findPublishedByAlias(\Environment::get('request'));
     if ($objParticipation !== null) {
         $blnAddParticipation = true;
         // only one participation per alias is supported yet
         if ($objParticipation instanceof \Model\Collection) {
             $objParticipation = $objParticipation->current();
         }
         $objArchive = $objParticipation->getRelated('pid');
         if ($objArchive === null) {
             $blnAddParticipation = false;
         }
         // check if current page is in defined root
         if ($objArchive->defineRoot && $objArchive->rootPage > 0) {
             $objCurrentRootPage = \Frontend::getRootPageFromUrl();
             $objRootPage = \PageModel::findByPk($objArchive->rootPage);
             if ($objRootPage !== null && $objCurrentRootPage !== null) {
                 if ($objRootPage->domain != $objCurrentRootPage->domain) {
                     $blnAddParticipation = false;
                     ParticipationController::removeActiveParticipation();
                 }
             }
         }
         if ($blnAddParticipation) {
             ParticipationController::setActiveParticipation($objParticipation);
             if ($objArchive->addInfoMessage && $objArchive->infoMessageWith !== '') {
                 ParticipationMessage::addInfo(\String::parseSimpleTokens($objArchive->infoMessageWith, array('participation' => ParticipationController::getParticipationLabel($objParticipation, '', true))), PARTICIPATION_MESSAGEKEY_ACTIVE);
             }
         }
         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()));
             }
         }
     }
     return $arrFragments;
 }