/**
     * Generate the main settings formular:
     *
     * @return void
     * @todo Define visibility
     */
    public function main()
    {
        global $LANG;
        if ($this->languageUpdate) {
            $this->doc->JScodeArray['languageUpdate'] .= '
				if (top.refreshMenu) {
					top.refreshMenu();
				} else {
					top.TYPO3ModuleMenu.refreshMenu();
				}
			';
        }
        if ($this->pagetreeNeedsRefresh) {
            \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree');
        }
        // Start page:
        $this->doc->loadJavascriptLib('md5.js');
        // Use a wrapper div
        $this->content .= '<div id="user-setup-wrapper">';
        // Load available backend modules
        $this->loadModules = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
        $this->loadModules->observeWorkspaces = TRUE;
        $this->loadModules->load($GLOBALS['TBE_MODULES']);
        $this->content .= $this->doc->header($LANG->getLL('UserSettings'));
        // Show if setup was saved
        if ($this->setupIsUpdated && !$this->tempDataIsCleared && !$this->settingsAreResetToDefault) {
            $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('setupWasUpdated'), $LANG->getLL('UserSettings'));
            $this->content .= $flashMessage->render();
        }
        // Show if temporary data was cleared
        if ($this->tempDataIsCleared) {
            $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('tempDataClearedFlashMessage'), $LANG->getLL('tempDataCleared'));
            $this->content .= $flashMessage->render();
        }
        // Show if temporary data was cleared
        if ($this->settingsAreResetToDefault) {
            $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('settingsAreReset'), $LANG->getLL('resetConfiguration'));
            $this->content .= $flashMessage->render();
        }
        // Notice
        if ($this->setupIsUpdated || $this->settingsAreResetToDefault) {
            $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('activateChanges'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO);
            $this->content .= $flashMessage->render();
        }
        // If password is updated, output whether it failed or was OK.
        if ($this->passwordIsSubmitted) {
            if ($this->passwordIsUpdated) {
                $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('newPassword_ok'), $LANG->getLL('newPassword'));
            } else {
                $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('newPassword_failed'), $LANG->getLL('newPassword'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
            }
            $this->content .= $flashMessage->render();
        }
        // Render the menu items
        $menuItems = $this->renderUserSetup();
        $this->content .= $this->doc->getDynTabMenu($menuItems, 'user-setup', FALSE, FALSE, 1, FALSE, 1, $this->dividers2tabs);
        $formToken = $this->formProtection->generateToken('BE user setup', 'edit');
        $this->content .= $this->doc->section('', '<input type="hidden" name="simUser" value="' . $this->simUser . '" />
			<input type="hidden" name="formToken" value="' . $formToken . '" />
			<input type="hidden" value="1" name="data[save]" />
			<input type="hidden" name="data[setValuesToDefault]" value="0" id="setValuesToDefault" />
			<input type="hidden" name="data[clearSessionVars]" value="0" id="clearSessionVars" />');
        // End of wrapper div
        $this->content .= '</div>';
        // Setting up the buttons and markers for docheader
        $docHeaderButtons = $this->getButtons();
        $markers['CSH'] = $docHeaderButtons['csh'];
        $markers['CONTENT'] = $this->content;
        // Build the <body> for the module
        $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
        // Renders the module page
        $this->content = $this->doc->render($LANG->getLL('UserSettings'), $this->content);
    }
 /**
  * Generate the main settings form:
  *
  * @return void
  */
 public function main()
 {
     $this->content .= '<form action="' . BackendUtility::getModuleUrl('user_setup') . '" method="post" id="SetupModuleController" name="usersetup" enctype="multipart/form-data">';
     if ($this->languageUpdate) {
         $this->moduleTemplate->addJavaScriptCode('languageUpdate', '
             if (top && top.TYPO3.ModuleMenu.App) {
                 top.TYPO3.ModuleMenu.App.refreshMenu();
             }
         ');
     }
     if ($this->pagetreeNeedsRefresh) {
         BackendUtility::setUpdateSignal('updatePageTree');
     }
     // Start page:
     $this->moduleTemplate->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/md5.js');
     // Use a wrapper div
     $this->content .= '<div id="user-setup-wrapper">';
     // Load available backend modules
     $this->loadModules = GeneralUtility::makeInstance(ModuleLoader::class);
     $this->loadModules->observeWorkspaces = true;
     $this->loadModules->load($GLOBALS['TBE_MODULES']);
     $this->content .= $this->doc->header($this->getLanguageService()->getLL('UserSettings'));
     // Show if setup was saved
     if ($this->setupIsUpdated && !$this->settingsAreResetToDefault) {
         $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('setupWasUpdated'), $this->getLanguageService()->getLL('UserSettings'));
         $this->content .= $flashMessage->render();
     }
     // Show if temporary data was cleared
     if ($this->settingsAreResetToDefault) {
         $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('settingsAreReset'), $this->getLanguageService()->getLL('resetConfiguration'));
         $this->content .= $flashMessage->render();
     }
     // Notice
     if ($this->setupIsUpdated || $this->settingsAreResetToDefault) {
         $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('activateChanges'), '', FlashMessage::INFO);
         $this->content .= $flashMessage->render();
     }
     // If password is updated, output whether it failed or was OK.
     if ($this->passwordIsSubmitted) {
         $flashMessage = null;
         switch ($this->passwordIsUpdated) {
             case self::PASSWORD_OLD_WRONG:
                 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('oldPassword_failed'), $this->getLanguageService()->getLL('newPassword'), FlashMessage::ERROR);
                 break;
             case self::PASSWORD_NOT_THE_SAME:
                 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('newPassword_failed'), $this->getLanguageService()->getLL('newPassword'), FlashMessage::ERROR);
                 break;
             case self::PASSWORD_UPDATED:
                 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('newPassword_ok'), $this->getLanguageService()->getLL('newPassword'));
                 break;
         }
         if ($flashMessage) {
             $this->content .= $flashMessage->render();
         }
     }
     // Render user switch
     $this->content .= $this->renderSimulateUserSelectAndLabel();
     // Render the menu items
     $menuItems = $this->renderUserSetup();
     $this->content .= $this->moduleTemplate->getDynamicTabMenu($menuItems, 'user-setup', 1, false, false);
     $formToken = $this->formProtection->generateToken('BE user setup', 'edit');
     $this->content .= '<div>';
     $this->content .= '<input type="hidden" name="simUser" value="' . $this->simUser . '" />
         <input type="hidden" name="formToken" value="' . $formToken . '" />
         <input type="hidden" value="1" name="data[save]" />
         <input type="hidden" name="data[setValuesToDefault]" value="0" id="setValuesToDefault" />';
     $this->content .= '</div>';
     // End of wrapper div
     $this->content .= '</div>';
     // Setting up the buttons and markers for docheader
     $this->getButtons();
     // Build the <body> for the module
     // Renders the module page
     $this->moduleTemplate->setContent($this->content);
     $this->content .= '</form>';
 }
 /**
  * Create session token
  *
  * @param   string $formName    Form name/Session token name
  * @return  string
  */
 protected function _sessionToken($formName)
 {
     $token = $this->_formProtection->generateToken($formName);
     return $token;
 }
 /**
  * @test
  */
 public function generateTokenReadsTokenFromSessionData()
 {
     $this->backendUserMock->expects($this->once())->method('getSessionData')->with('formProtectionSessionToken')->will($this->returnValue(array()));
     $this->subject->generateToken('foo');
 }
Beispiel #5
0
 /**
  * Generate the main settings form:
  *
  * @return void
  */
 public function main()
 {
     $this->content .= '<form action="' . BackendUtility::getModuleUrl('user_setup') . '" method="post" id="SetupModuleController" name="usersetup" enctype="multipart/form-data">';
     if ($this->languageUpdate) {
         $this->moduleTemplate->addJavaScriptCode('languageUpdate', '
             if (top && top.TYPO3.ModuleMenu.App) {
                 top.TYPO3.ModuleMenu.App.refreshMenu();
             }
         ');
     }
     if ($this->pagetreeNeedsRefresh) {
         BackendUtility::setUpdateSignal('updatePageTree');
     }
     // Start page:
     $this->moduleTemplate->getPageRenderer()->addJsFile('EXT:backend/Resources/Public/JavaScript/md5.js');
     // Use a wrapper div
     $this->content .= '<div id="user-setup-wrapper">';
     // Load available backend modules
     $this->loadModules = GeneralUtility::makeInstance(ModuleLoader::class);
     $this->loadModules->observeWorkspaces = true;
     $this->loadModules->load($GLOBALS['TBE_MODULES']);
     $this->content .= $this->moduleTemplate->header($this->getLanguageService()->getLL('UserSettings'));
     $this->addFlashMessages();
     // Render user switch
     $this->content .= $this->renderSimulateUserSelectAndLabel();
     // Render the menu items
     $menuItems = $this->renderUserSetup();
     $this->content .= $this->moduleTemplate->getDynamicTabMenu($menuItems, 'user-setup', 1, false, false);
     $formToken = $this->formProtection->generateToken('BE user setup', 'edit');
     $this->content .= '<div>';
     $this->content .= '<input type="hidden" name="simUser" value="' . (int) $this->simUser . '" />
         <input type="hidden" name="formToken" value="' . htmlspecialchars($formToken) . '" />
         <input type="hidden" value="1" name="data[save]" />
         <input type="hidden" name="data[setValuesToDefault]" value="0" id="setValuesToDefault" />';
     $this->content .= '</div>';
     // End of wrapper div
     $this->content .= '</div>';
     // Setting up the buttons and markers for docheader
     $this->getButtons();
     // Build the <body> for the module
     // Renders the module page
     $this->moduleTemplate->setContent($this->content);
     $this->content .= '</form>';
 }
    /**
     * Generate the main settings form:
     *
     * @return void
     */
    public function main()
    {
        if ($this->languageUpdate) {
            $this->doc->JScodeArray['languageUpdate'] .= '
				if (top.refreshMenu) {
					top.refreshMenu();
				} else {
					top.TYPO3ModuleMenu.refreshMenu();
				}
			';
        }
        if ($this->pagetreeNeedsRefresh) {
            BackendUtility::setUpdateSignal('updatePageTree');
        }
        // Start page:
        $this->doc->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/md5.js');
        // Use a wrapper div
        $this->content .= '<div id="user-setup-wrapper">';
        // Load available backend modules
        $this->loadModules = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Module\ModuleLoader::class);
        $this->loadModules->observeWorkspaces = TRUE;
        $this->loadModules->load($GLOBALS['TBE_MODULES']);
        $this->content .= $this->doc->header($this->getLanguageService()->getLL('UserSettings'));
        // Show if setup was saved
        if ($this->setupIsUpdated && !$this->tempDataIsCleared && !$this->settingsAreResetToDefault) {
            $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('setupWasUpdated'), $this->getLanguageService()->getLL('UserSettings'));
            $this->content .= $flashMessage->render();
        }
        // Show if temporary data was cleared
        if ($this->tempDataIsCleared) {
            $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('tempDataClearedFlashMessage'), $this->getLanguageService()->getLL('tempDataCleared'));
            $this->content .= $flashMessage->render();
        }
        // Show if temporary data was cleared
        if ($this->settingsAreResetToDefault) {
            $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('settingsAreReset'), $this->getLanguageService()->getLL('resetConfiguration'));
            $this->content .= $flashMessage->render();
        }
        // Notice
        if ($this->setupIsUpdated || $this->settingsAreResetToDefault) {
            $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('activateChanges'), '', FlashMessage::INFO);
            $this->content .= $flashMessage->render();
        }
        // If password is updated, output whether it failed or was OK.
        if ($this->passwordIsSubmitted) {
            $flashMessage = NULL;
            switch ($this->passwordIsUpdated) {
                case self::PASSWORD_OLD_WRONG:
                    $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('oldPassword_failed'), $this->getLanguageService()->getLL('newPassword'), FlashMessage::ERROR);
                    break;
                case self::PASSWORD_NOT_THE_SAME:
                    $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('newPassword_failed'), $this->getLanguageService()->getLL('newPassword'), FlashMessage::ERROR);
                    break;
                case self::PASSWORD_UPDATED:
                    $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('newPassword_ok'), $this->getLanguageService()->getLL('newPassword'));
                    break;
            }
            if ($flashMessage) {
                $this->content .= $flashMessage->render();
            }
        }
        // Render user switch
        $this->content .= $this->renderSimulateUserSelectAndLabel();
        // Render the menu items
        $menuItems = $this->renderUserSetup();
        $this->content .= $this->doc->getDynamicTabMenu($menuItems, 'user-setup', 1, FALSE, FALSE);
        $formToken = $this->formProtection->generateToken('BE user setup', 'edit');
        $this->content .= $this->doc->section('', '<input type="hidden" name="simUser" value="' . $this->simUser . '" />
			<input type="hidden" name="formToken" value="' . $formToken . '" />
			<input type="hidden" value="1" name="data[save]" />
			<input type="hidden" name="data[setValuesToDefault]" value="0" id="setValuesToDefault" />
			<input type="hidden" name="data[clearSessionVars]" value="0" id="clearSessionVars" />');
        // End of wrapper div
        $this->content .= '</div>';
        // Setting up the buttons and markers for docheader
        $docHeaderButtons = $this->getButtons();
        $markers['CSH'] = $docHeaderButtons['csh'];
        $markers['CONTENT'] = $this->content;
        // Build the <body> for the module
        $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
        // Renders the module page
        $this->content = $this->doc->render($this->getLanguageService()->getLL('UserSettings'), $this->content);
    }