예제 #1
0
 public function __construct()
 {
     parent::__construct(false);
     $this->sAction = 'login';
     if (Manager::isPost()) {
         ArrayUtil::trimStringsInArray($_POST);
     }
     //1st step: user clicked on the recovery link
     //	• Display email field
     if (isset($_REQUEST['password_forgotten'])) {
         $this->sAction = 'password_forgotten';
     }
     //2nd step: user has entered an email address
     //	• Send the email with the recovery link (and generate the hint)
     //	• Add confirmation message to flash
     if (isset($_POST['password_reset_user_name'])) {
         $this->sAction = self::processPasswordReset();
     }
     //3rd step: user has clicked on the reset link in the e-mail
     //	• Validate the hint
     //	• Display a form for entering a new password (form also contains hidden fields for email and hint)
     //	• Add the referrer to the session (again)
     if (isset($_REQUEST['recover_username'])) {
         $this->sAction = self::passwordReset();
     }
     //4th step: user has submitted the new password
     //	• Validate the hint (again)
     //	• Validate password constraints
     //	• Set the new password (if valid)
     //	• Log in (if valid)
     //	• Redirect to the referrer (if valid)
     if (isset($_POST['new_password'])) {
         $this->sAction = self::loginNewPassword();
     }
     if (isset($_POST[self::USER_NAME])) {
         self::login();
     }
     $oOutput = new XHTMLOutput('transitional');
     $oOutput->render();
     $this->oTemplate = new Template('login', array(DIRNAME_TEMPLATES, 'login'), false, true);
 }
예제 #2
0
 public function display(Template $oTemplate, $bIsPreview = false)
 {
     if (Manager::isPost()) {
         ArrayUtil::trimStringsInArray($_POST);
     }
     //1st step: user clicked on the recovery link
     //	• Display email field
     if (isset($_REQUEST['password_forgotten'])) {
         $this->sAction = 'password_forgotten';
     }
     //2nd step: user has entered an email address
     //	• Send the email with the recovery link (and generate the hint)
     //	• Add confirmation message to flash
     if (isset($_POST['password_reset_user_name'])) {
         $this->sAction = LoginManager::processPasswordReset(LinkUtil::link($this->oPage->getFullPathArray(), 'FrontendManager'));
     }
     //3rd step: user has clicked on the reset link in the e-mail
     //	• Validate the hint
     //	• Display a form for entering a new password (form also contains hidden fields for email and hint)
     //	• Add the referrer to the session (again)
     if (isset($_REQUEST['recover_username'])) {
         $this->sAction = LoginManager::passwordReset();
     }
     //4th step: user has submitted the new password
     //	• Validate the hint (again)
     //	• Validate password constraints
     //	• Set the new password (if valid)
     //	• Log in (if valid)
     //	• Redirect to the referrer (if valid)
     if (isset($_POST['new_password'])) {
         $this->sAction = LoginManager::loginNewPassword(LinkUtil::link($this->oPage->getFullPathArray()));
     }
     if (isset($_POST[LoginManager::USER_NAME])) {
         LoginManager::login(null, null, LinkUtil::link($this->oPage->getFullPathArray()));
     }
     parent::display($oTemplate, $bIsPreview);
 }
 /**
  * newsletterUnsubscribe()
  *
  * Description
  * • check if requested url is valid
  * • display opt-out options if request method is get or post is invalid
  * • process unsubscribe action if the request method is post
  * • cleanup subscriber membership and subscriber as fallback
  *
  * @return Template
  */
 private function newsletterUnsubscribe()
 {
     if (!isset($_REQUEST['unsubscribe'])) {
         return $this->constructTemplate('unsubscribe_unknown_error');
     }
     // Process unsubscribe opt_out form if post
     $oSubscriber = SubscriberQuery::create()->filterByEmail($_REQUEST['unsubscribe'])->findOne();
     if (Manager::isPost()) {
         $mOutput = $this->processOptOutSuscriptions($oSubscriber);
         if ($mOutput) {
             return $mOutput;
         }
     }
     // If subscriber does not exist or the required checksum is not correct, return error message
     if (!($oSubscriber && $oSubscriber->getUnsubscribeChecksum() === $_REQUEST['checksum'])) {
         return $this->constructTemplate('unsubscribe_unknown_error');
     }
     SubscriberPeer::ignoreRights(true);
     // Count valid subscriptions [with display_name, not temp or import groups]
     $aSubscriberGroupMemberShips = $oSubscriber->getSubscriberGroupMemberships();
     $aValidSubscriptions = array();
     if (count($aSubscriberGroupMemberShips) > 1) {
         foreach ($aSubscriberGroupMemberShips as $oSubscriberGroupMembership) {
             if ($oSubscriberGroupMembership->getSubscriberGroup()->getDisplayName() == null) {
                 continue;
             }
             $aValidSubscriptions[] = $oSubscriberGroupMembership;
         }
     }
     // Display view with opt_out options if there is more then one valid subscription
     if (count($aValidSubscriptions) > 1) {
         $oTemplate = $this->constructTemplate('unsubscribe_optout_form');
         $oTemplate->replaceIdentifier('checksum', $_REQUEST['checksum']);
         $oTemplate->replaceIdentifier('email', $oSubscriber->getEmail());
         $bIsPostAndAllUnchecked = Manager::isPost() && !isset($_POST['subscriber_group_id']);
         foreach ($aValidSubscriptions as $oSubscriberGroupMemberships) {
             $oCheckboxTemplate = $this->constructTemplate('unsubscribe_optout_checkbox');
             $oCheckboxTemplate->replaceIdentifier('subscriber_group_id', $oSubscriberGroupMemberships->getSubscriberGroupId());
             $oCheckboxTemplate->replaceIdentifier('subscriber_group_name', $oSubscriberGroupMemberships->getSubscriberGroup()->getDisplayName());
             $oCheckboxTemplate->replaceIdentifier('checked', !$bIsPostAndAllUnchecked ? ' checked="checked"' : '', null, Template::NO_HTML_ESCAPE);
             $oTemplate->replaceIdentifierMultiple('subscriber_group_checkbox', $oCheckboxTemplate);
         }
         return $oTemplate;
     }
     // Delete subscriber because there is not a valid subscription (all temp subscriptions are removed too)
     $oSubscriber->delete();
     // Display unsubscribe confirmation international
     return $this->constructTemplate('unsubscribe_confirm');
 }
예제 #4
0
 /**
  * render()
  */
 public function render()
 {
     FilterModule::getFilters()->handleRequestStarted();
     $bIsDynamic = false;
     $bIsAjaxRequest = Manager::isPost() && Manager::isXMLHttpRequest();
     $aAjaxSections = array('container' => array(), 'navigation' => array());
     ///@todo remove legacy support when the need fades
     $bIsLegacyAjaxRequest = $bIsAjaxRequest && isset($_REQUEST['container_only']);
     if ($bIsAjaxRequest) {
         if ($bIsLegacyAjaxRequest) {
             $_REQUEST['ajax_containers'] = array($_REQUEST['container_only']);
         }
         if (isset($_REQUEST['ajax_containers'])) {
             sort($_REQUEST['ajax_containers']);
             $aAjaxSections['container'] = $_REQUEST['ajax_containers'];
         }
         if (isset($_REQUEST['ajax_navigations'])) {
             sort($_REQUEST['ajax_navigations']);
             $aAjaxSections['navigation'] = $_REQUEST['ajax_navigations'];
         }
         if (isset($_REQUEST['ajax_title'])) {
             $aAjaxSections = array_merge($aAjaxSections, array('page_title' => true, 'link_text' => true, 'title' => true));
         }
         asort($aAjaxSections);
     }
     $sPageType = self::$CURRENT_PAGE->getPageType();
     $this->oPageType = PageTypeModule::getModuleInstance($sPageType, self::$CURRENT_PAGE, self::$CURRENT_NAVIGATION_ITEM);
     $aAllowedParams = $this->oPageType->acceptedRequestParams($bIsAjaxRequest ? $aAjaxSections['container'] : null);
     $bParamsNotAllowed = count(array_intersect($this->aPathRequestParams, $aAllowedParams)) !== count($this->aPathRequestParams);
     $this->bIsNotFound = $this->bIsNotFound || $bParamsNotAllowed;
     FilterModule::getFilters()->handlePageNotFoundDetectionComplete($this->bIsNotFound, self::$CURRENT_PAGE, self::$CURRENT_NAVIGATION_ITEM, array(&$this->bIsNotFound));
     if ($this->bIsNotFound) {
         FilterModule::getFilters()->handlePageNotFound();
         LinkUtil::sendHTTPStatusCode(404, 'Not Found');
         $sErrorPageName = Settings::getSetting('error_pages', 'not_found', null);
         $oPage = null;
         if ($sErrorPageName) {
             $oPage = PageQuery::create()->findOneByName($sErrorPageName);
         }
         if ($oPage === null) {
             die(TranslationPeer::getString('wns.page.not_found'));
         }
         self::$CURRENT_PAGE = $oPage;
         self::$CURRENT_NAVIGATION_ITEM = PageNavigationItem::navigationItemForPage($oPage);
         //Set correct page type of 404 page
         $sPageType = self::$CURRENT_PAGE->getPageType();
         $this->oPageType = PageTypeModule::getModuleInstance($sPageType, self::$CURRENT_PAGE);
     } else {
         $this->addCanonicalLink();
     }
     if (!$bIsAjaxRequest) {
         $oOutput = $this->getXHTMLOutput();
         $oOutput->render();
     } else {
         if (!$bIsLegacyAjaxRequest) {
             header("Content-Type: application/json;charset=utf-8");
         }
     }
     $sPageIdentifier = implode('/', self::$CURRENT_NAVIGATION_ITEM->getLink()) . '_' . Session::language();
     if ($bIsAjaxRequest) {
         $sPageIdentifier .= '_' . serialize($aAjaxSections);
     }
     // Init the template
     if ($bIsLegacyAjaxRequest) {
         $this->oTemplate = new Template(TemplateIdentifier::constructIdentifier('container', $_REQUEST['container_only']), null, true, true);
     } else {
         if ($bIsAjaxRequest) {
             $this->oTemplate = new AjaxTemplate($aAjaxSections, true);
         } else {
             $this->oTemplate = self::$CURRENT_PAGE->getTemplate(true);
         }
     }
     FilterModule::getFilters()->handleBeforePageFill(self::$CURRENT_PAGE, $this->oTemplate);
     if (!$bIsLegacyAjaxRequest) {
         $this->fillAttributes();
         $this->fillNavigation();
         $this->fillAutofill();
     }
     $this->fillContent();
     $this->renderTemplate();
     while (ob_get_level() > 0) {
         ob_end_flush();
     }
     FilterModule::getFilters()->handleRequestFinished(array(self::$CURRENT_PAGE, $bIsDynamic, $bIsAjaxRequest));
 }
 private function displayAddComment($oTemplate)
 {
     if ($this->oEntry === null) {
         return $this->displayEntry($oTemplate);
     }
     if (!$this->oEntry->commentsEnabled()) {
         LinkUtil::redirect(LinkUtil::link($this->oEntry->getLink()));
     }
     if (Manager::isPost() && isset($_POST['preview'])) {
         $oComment = $_POST['preview'];
         $oTemplate->replaceIdentifier('container', $this->renderComments(array($oComment), $this->oEntry), $this->sContainer);
         return;
     }
     $oTemplate->replaceIdentifier('container', $this->renderAddComment($this->oEntry), $this->sContainer);
 }
예제 #6
0
 public function onPageHasBeenSet($oPage, $bIsNotFound, $oNavigationItem)
 {
     if ($bIsNotFound || !$oPage->isOfType('journal')) {
         return;
     }
     // If is feed then render feed
     if ($oNavigationItem instanceof VirtualNavigationItem && $oNavigationItem->getType() === 'journal-feed') {
         $oFeed = new JournalFileModule(false, $oPage, $oNavigationItem->getData());
         $oFeed->renderFile();
         exit;
     } else {
         if ($oNavigationItem instanceof VirtualNavigationItem && $oNavigationItem->getType() === 'journal-add_comment' && Manager::isPost()) {
             $oEntry = $oNavigationItem->getData();
             if (!$oEntry->commentsEnabled()) {
                 LinkUtil::redirect(LinkUtil::link($oEntry->getLink()));
             }
             $this->handleNewJournalComment($oPage, $oEntry);
         }
     }
     //Add the feed include
     ResourceIncluder::defaultIncluder()->addCustomResource(array('template' => 'feed', 'location' => LinkUtil::link($oPage->getLinkArray('feed'))));
 }