public function __construct($aRequestPath) { parent::__construct($aRequestPath); $sBase = Manager::usePath(); $iId = Manager::usePath(); // Base path "newsletter" > display newsletter if ($sBase === 'newsletter') { $iId = is_numeric($sBase) ? $sBase : $iId; $this->oNewsletter = NewsletterQuery::create()->findPk($iId); if ($this->oNewsletter === null) { throw new Exception('No such newsletter exists'); } } else { if ($sBase === 'mailing') { $this->oMailing = NewsletterMailingQuery::create()->findPk($iId); if ($this->oMailing === null) { throw new Exception('No such mailing exists'); } $this->oNewsletter = $this->oMailing->getNewsletter(); } elseif (is_numeric($sBase)) { $this->oNewsletter = NewsletterQuery::create()->findPk($sBase); } } // Throw exception if no newsletter is found if ($this->oNewsletter === null) { throw new Exception('Error in DisplayNewsletterFileModule::__construct(): No such newsletter exists'); } // Optional handling of authentication FilterModule::getFilters()->handleNewsletterDisplayRequested($this->oNewsletter); }
private static function writeTagForIdentifier($sTagName, $aParameters, $oIdentifier, $sTagContent = null, $mCallbackContext = null) { if ($sTagContent === null) { $sTagContent = $oIdentifier->getParameter("link_text"); } FilterModule::getFilters()->handleRichtextWriteTagForIdentifier($sTagName, array(&$aParameters), $oIdentifier, $sTagContent, $mCallbackContext); $oWriter = new TagWriter($sTagName, array(), $sTagContent); foreach ($aParameters as $sName => $sValue) { $oWriter->setParameter($sName, $sValue); } return self::writeTagForIdentifierWithWriter($oIdentifier, $oWriter); }
public function listMailGroups($bIncludeExternalMailGroups = true, $bIncludeGeneratedMailGroups = true) { // Get subscriber groups with membership count in not used for subscriber import $bUsedForSubscriberImport = $bIncludeExternalMailGroups === false && ($bIncludeGeneratedMailGroups = false); $oQuery = SubscriberGroupQuery::create()->excludeTemporary($bIncludeGeneratedMailGroups)->orderByName(); $aMailGroups = array(); foreach ($oQuery->find() as $oSubscriberGroup) { $sId = (string) $oSubscriberGroup->getId(); $aMailGroups[$sId] = $oSubscriberGroup->getName() . (!$bUsedForSubscriberImport ? ' (' . $oSubscriberGroup->countSubscriberGroupMemberships() . ')' : ''); } // If filter is implemented in project this allows to add on-the-fly mail groups // E.g. a group of recipients that have registered for an event and there for create a temporary mail group if ($bIncludeExternalMailGroups) { FilterModule::getFilters()->handleMailGroups(array(&$aMailGroups)); } return $aMailGroups; }
private function prepareChildren() { if ($this->aCustomChildren !== null) { return; } $sCacheKey = Session::language() . '/' . $this->getId(); $oCache = new Cache("{$sCacheKey}/custom-children", 'navigation'); if ($oCache->entryExists()) { // Not setting validators will result in the cache being always up-to-date $bIsOutdated = false; FilterModule::getFilters()->handleNavigationItemChildrenCacheDetectOutdated($this, $oCache, array(&$bIsOutdated)); if (!$bIsOutdated) { $this->aCustomChildren = $oCache->getContentsAsVariable(); foreach ($this->aCustomChildren as $oChildNavigationItem) { $oChildNavigationItem->oParent = $this; } return; } } $this->aCustomChildren = array(); FilterModule::getFilters()->handleNavigationItemChildrenRequested($this); $oCache->setContents($this->aCustomChildren, true); }
public function mayOperate($sOperation, $oUser = false) { $oUser = RightPeer::getRightsUser($oUser); $bIsAllowed = false; if ($oUser && ($this->isNew() || $this->getCreatedBy() === $oUser->getId()) && RightPeer::mayOperateOnOwn($oUser, $this, $sOperation)) { $bIsAllowed = true; } else { if (RightPeer::mayOperateOn($oUser, $this, $sOperation)) { $bIsAllowed = true; } } FilterModule::getFilters()->handleRightOperationCheck($sOperation, $this, $oUser, array(&$bIsAllowed)); return $bIsAllowed; }
public function mayOperate($sOperation, $oUser = false) { if ($oUser === false) { $oUser = Session::getSession()->getUser(); } $bIsAllowed = false; if ($oUser && ($this->isNew() || $this->getCreatedBy() === $oUser->getId()) && NewsletterPeer::mayOperateOnOwn($oUser, $this, $sOperation)) { $bIsAllowed = true; } else { if (NewsletterPeer::mayOperateOn($oUser, $this, $sOperation)) { $bIsAllowed = true; } } FilterModule::getFilters()->handleNewsletterOperationCheck($sOperation, $this, $oUser, array(&$bIsAllowed)); return $bIsAllowed; }
private function loginUser($oUser) { $iReturnValue = self::USER_IS_VALID; if (!$oUser->getIsBackendLoginEnabled()) { $iReturnValue |= self::USER_IS_FRONTEND_ONLY; } if ($oUser->getIsInactive()) { $iReturnValue |= self::USER_IS_INACTIVE; $iReturnValue &= ~self::USER_IS_VALID; } //Actual login if (($iReturnValue & self::USER_IS_VALID) === self::USER_IS_VALID) { $this->oUser = $oUser; $this->iUserId = $oUser->getId(); if (UserQuery::create()->count() === 1 && $this->oUser->getFirstName() == '') { // user firstname can only (should only) be empty if it is the default user $iReturnValue |= self::USER_IS_DEFAULT_USER; } } FilterModule::getFilters()->handleUserLoggedIn($oUser, array(&$iReturnValue)); return $iReturnValue; }
protected function fillAttributes() { FilterModule::getFilters()->handleFillPageAttributes(self::$CURRENT_PAGE, $this->oTemplate); $oMetaIncluder = ResourceIncluder::metaIncluder(); $sKeywords = self::$CURRENT_PAGE->getConsolidatedKeywords(); $sDescription = self::$CURRENT_PAGE->getDescription(); $oMetaIncluder->addMeta('keywords', $sKeywords); $oMetaIncluder->addMeta('description', $sDescription); // FIXME: Deprecated. Use the meta includer for this. $this->oTemplate->replaceIdentifier("meta_keywords", $sKeywords); $this->oTemplate->replaceIdentifier("meta_description", $sDescription); $this->oTemplate->replaceIdentifier("description", self::$CURRENT_NAVIGATION_ITEM->getDescription()); $this->oTemplate->replaceIdentifier("title", self::$CURRENT_NAVIGATION_ITEM->getTitle()); $this->oTemplate->replaceIdentifier("level", self::$CURRENT_NAVIGATION_ITEM->getLevel()); $this->oTemplate->replaceIdentifier("link_text", self::$CURRENT_NAVIGATION_ITEM->getLinkText()); $this->oTemplate->replaceIdentifier("navigation_name", self::$CURRENT_NAVIGATION_ITEM->getName()); $this->oTemplate->replaceIdentifier("navigation_title", self::$CURRENT_NAVIGATION_ITEM->getTitle()); $this->oTemplate->replaceIdentifier("page_link_text", self::$CURRENT_PAGE->getLinkText()); $this->oTemplate->replaceIdentifier("page_name", self::$CURRENT_PAGE->getName()); $this->oTemplate->replaceIdentifier("page_title", self::$CURRENT_PAGE->getPageTitle()); foreach (self::$CURRENT_PAGE->getPageProperties() as $oPageProperty) { $this->oTemplate->replaceIdentifier('pageProperty', $oPageProperty->getValue(), $oPageProperty->getName()); } $this->oTemplate->replaceIdentifier("page_type", self::$CURRENT_PAGE->getPageType()); $this->oTemplate->replaceIdentifier("page_id", self::$CURRENT_PAGE->getId()); $this->oTemplate->replaceIdentifier("page_identifier", self::$CURRENT_NAVIGATION_ITEM->getIdentifier()); $this->oTemplate->replaceIdentifierCallback("page_link", 'FrontendManager', 'replacePageLinkIdentifier'); if (Settings::getSetting('general', 'multilingual', true) && $this->oTemplate->hasIdentifier('language_chooser')) { $this->oTemplate->replaceIdentifier("language_chooser", Navigation::getLanguageChooser($this->oTemplate), null, Template::NO_HTML_ESCAPE); } FilterModule::getFilters()->handleFillAttributesFinished(self::$CURRENT_PAGE, $this->oTemplate); }
private function index(array $aPath) { $oNavigationItem = $this->oRootNavigationItem; PageNavigationItem::clearCache(); while (count($aPath) > 0) { $oNavigationItem = $oNavigationItem->namedChild(array_shift($aPath), $this->sLanguageId, true, true); } FilterModule::getFilters()->handleNavigationPathFound($this->oRootNavigationItem, $oNavigationItem); FrontendManager::$CURRENT_NAVIGATION_ITEM = $oNavigationItem; $oPageNavigationItem = $oNavigationItem; while (!$oPageNavigationItem instanceof PageNavigationItem) { $oPageNavigationItem = $oPageNavigationItem->getParent(); } FrontendManager::$CURRENT_PAGE = $oPageNavigationItem->getMe(); $oPage = FrontendManager::$CURRENT_PAGE; $bIsNotFound = false; FilterModule::getFilters()->handlePageHasBeenSet($oPage, $bIsNotFound, $oNavigationItem); FilterModule::getFilters()->handleRequestStarted(); FilterModule::getFilters()->handlePageNotFoundDetectionComplete($bIsNotFound, $oPage, $oNavigationItem, array(&$bIsNotFound)); if ($bIsNotFound) { return false; } $sDescription = $oNavigationItem->getDescription($this->sLanguageId); if ($sDescription === null) { $sDescription = $oPage->getDescription($this->sLanguageId); } $aKeywords = array(); foreach ($oPage->getConsolidatedKeywords($this->sLanguageId, true) as $sKeyword) { $aKeywords = array_merge($aKeywords, StringUtil::getWords($sKeyword)); } $sTitle = $oNavigationItem->getTitle($this->sLanguageId); $sLinkText = $oNavigationItem->getLinkText($this->sLanguageId); if (!$sLinkText) { $sLinkText = $sTitle; } $sName = $oNavigationItem->getName(); // Page type can prevent indexing if (!self::doIndex($oPage->getPageType(), $oNavigationItem)) { return false; } $oPageType = PageTypeModule::getModuleInstance($oPage->getPageType(), $oPage, $oNavigationItem); $aWords = $oPageType->getWords(); $aWords = array_merge($aWords, StringUtil::getWords($sDescription), $aKeywords, StringUtil::getWords($sTitle), StringUtil::getWords($sLinkText), array($sName)); $aPagePath = $oPage->getLink(); $aNavigationItemPath = $oNavigationItem->getLink(); $sPath = implode('/', array_diff($aNavigationItemPath, $aPagePath)); $oSearchIndex = new SearchIndex(); $oSearchIndex->setPageId($oPage->getId()); $oSearchIndex->setPath($sPath); $oSearchIndex->setLinkText($sLinkText); $oSearchIndex->setPageTitle($sTitle); $oSearchIndex->setLanguageId($this->sLanguageId); $oSearchIndex->save(); foreach ($aWords as $sWord) { $sWord = Synonyms::rootFor($sWord, $this->sLanguageId); $oSearchIndexWord = SearchIndexWordQuery::create()->filterBySearchIndex($oSearchIndex)->filterByWord($sWord)->findOne(); if ($oSearchIndexWord === null) { $oSearchIndexWord = new SearchIndexWord(); $oSearchIndexWord->setSearchIndex($oSearchIndex); $oSearchIndexWord->setWord($sWord); } else { $oSearchIndexWord->incrementCount(); } $oSearchIndexWord->save(); } return true; }
/** prepareForSending() * * @param array of mail_group values [int subscriber_group_id, string external_mail_group] * @param string SenderMail * @param string SenderName * * description: prepare batch processing * • validates send form * * @return int batch count */ public function prepareForSending($aMailGroups = null, $sSenderEmail = null, $sSenderName = null) { if (!$sSenderEmail) { $sSenderEmail = LinkUtil::getDomainHolderEmail('newsletter'); } $this->sSenderEmail = $sSenderEmail; if ($sSenderName !== $sSenderEmail) { $this->sSenderName = $sSenderName; } $this->aRecipients = self::getSubscribersBySubscriberGroupMembership($aMailGroups); FilterModule::getFilters()->handleMailGroupsRecipients($aMailGroups, array(&$this->aRecipients)); // Validate prepareForSending $sError = null; if ($aMailGroups === null) { $sError = 'mail_group_required'; } else { if (count($this->aRecipients) === 0) { $sError = 'no_recipients_available'; } } $oFlash = new Flash(); if ($sError) { $oFlash->addMessage($sError); } $oFlash->finishReporting(); if ($oFlash->hasMessages()) { throw new ValidationException($oFlash); } $this->aMailGroups = is_array($aMailGroups) ? $aMailGroups : array($aMailGroups); return ceil(count($this->aRecipients) / $this->iBatchSize); }
/** * fillContainerWithModule() */ private function fillContainerWithModule($oContentObject, $oTemplate, $iModuleId) { $oPageContents = $oContentObject->getLanguageObject($this->sLanguageId); if ($this->bIsPreview && $oPageContents === null) { //Need to get unsaved drafts in preview $oPageContents = new LanguageObject(); $oPageContents->setLanguageId($this->sLanguageId); $oPageContents->setContentObject($oContentObject); $oPageContents = $oPageContents->getDraft(true); } if ($oPageContents === null) { return false; } if ($oContentObject->getConditionSerialized() !== null && !$this->bIsPreview) { $oConditionTemplate = unserialize(stream_get_contents($oContentObject->getConditionSerialized())); if ($oConditionTemplate->render() === '') { return false; } } $sObjectType = $oContentObject->getObjectType(); if (!Module::moduleExists($sObjectType, FrontendModule::getType()) || !Module::isModuleEnabled(FrontendModule::getType(), $sObjectType)) { $sLink = implode('/', $this->oNavigationItem->getLink()); ErrorHandler::handleError(E_WARNING, "Disabled or non-existing frontend module {$sObjectType} in use on page {$sLink} ({$this->sLanguageId})", __FILE__, __LINE__, null, debug_backtrace(), true); if ($this->bIsPreview) { $oTemplate->replaceIdentifierMultiple("container", "<strong>Disabled or non-existing frontend module {$sObjectType} in use!</strong>", null, Template::NO_HTML_ESCAPE); return true; } return false; } if ($this->bIsPreview) { $oModule = FrontendModule::getModuleInstance($oContentObject->getObjectType(), $oPageContents->getDraft(), $iModuleId); } else { $oModule = FrontendModule::getModuleInstance($oContentObject->getObjectType(), $oPageContents, $iModuleId); } $sFrontentContents = $this->getModuleContents($oModule); if ($sFrontentContents === null) { return false; } // module_id FilterModule::getFilters()->handleDefaultPageTypeFilledContainerWithModule($oContentObject, $oModule, $oTemplate, $this->oFrontendTemplate, $this->iModuleId); if ($this->bIsPreview) { $sFrontentContents = $this->getPreviewMarkup($oContentObject, $sFrontentContents); } $oTemplate->replaceIdentifierMultiple("container", $sFrontentContents, null, Template::NO_HTML_ESCAPE); if (($sCss = $oModule->getCssForFrontend()) !== null) { ResourceIncluder::defaultIncluder()->addCustomCss($sCss, ResourceIncluder::PRIORITY_LAST); } if (($sJs = $oModule->getJsForFrontend()) !== null) { ResourceIncluder::defaultIncluder()->addCustomJs($sJs, ResourceIncluder::PRIORITY_LAST); } return true; }
private static function handle($aError, $bNeverPrint = false, $bNeverNotifyDeveloper = false) { //Add additional information for logging/sending $aError['referrer'] = @$_SERVER['HTTP_REFERER']; $aError['host'] = @$_SERVER['HTTP_HOST']; $aError['path'] = @$_SERVER['REQUEST_URI']; $aError['request'] = @$_REQUEST; $aError['cookies'] = @$_COOKIE; FilterModule::getFilters()->handleAnyError(array(&$aError), $bNeverPrint, $bNeverNotifyDeveloper); if (!$bNeverNotifyDeveloper && self::shouldMailErrors()) { $sAddress = Settings::getSetting('developer', 'email', false); if (!$sAddress) { $sAddress = Settings::getSetting('domain_holder', 'email', false); } if ($sAddress) { FilterModule::getFilters()->handleErrorEmailSend(array(&$sAddress, &$aError)); mb_send_mail($sAddress, "Error in rapila on " . $aError['host'], $aError['path'] . "\n" . print_r($aError, true)); } } if (self::shouldLogErrors()) { $sLogFilePath = MAIN_DIR . '/' . DIRNAME_GENERATED . '/error.log'; $sErrorMessage = self::readableDump($aError); $iMode = 0; $sDestination = null; FilterModule::getFilters()->handleErrorLog(array(&$sLogFilePath, &$aError, &$sErrorMessage, &$iMode, &$sDestination)); error_log($sErrorMessage, $iMode, $sDestination); } if (!$bNeverPrint && self::shouldPrintErrors() && !(isset($aError['code']) && self::shouldContinue($aError['code']))) { FilterModule::getFilters()->handleErrorPrint(array(&$aError)); Util::dumpAll($aError); } }