#8995: Extension "felogin" - replace user fields in display messages
authorMartin Kutschker <martin.t.kutschker@blackbox.net>
Wed, 17 Sep 2008 21:52:51 +0000 (21:52 +0000)
committerMartin Kutschker <martin.t.kutschker@blackbox.net>
Wed, 17 Sep 2008 21:52:51 +0000 (21:52 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4143 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/felogin/ext_typoscript_setup.txt
typo3/sysext/felogin/pi1/class.tx_felogin_pi1.php

index c137572..db94f8d 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 2008-09-17  Martin Kutschker  <masi@typo3.org>
 
        * Added feature #1957: When deleting a record in the BE, the message should show the record label (thanx to Rob Vonk for the initial patch)
+       * Added feature #8995: Extension "felogin" - replace user fields in display messages (thanx to Steffen Kamper)
 
 2008-09-17  Stanislas Rolland  <typo3@sjbr.ca>
 
index be1c6c3..a3f2324 100644 (file)
@@ -60,7 +60,13 @@ plugin.tx_felogin_pi1 {
                wrap = <div>|</div>
        }
        
-       
+       # stdWrap for fe_users fields used in Messages
+       userfields {
+               username {
+                       htmlSpecialChars = 1
+                       wrap = <strong>|</strong>
+               }
+       }
        
                #redirect
        redirectMode =
index 1f8a4f2..b95077e 100644 (file)
@@ -59,10 +59,10 @@ class tx_felogin_pi1 extends tslib_pibase {
                        // Loading TypoScript array into object variable:
                $this->conf = $conf;
                $this->uploadDir = 'uploads/tx_felogin/';
-                       
+
                        // Loading default pivars
                $this->pi_setPiVarDefaults();
-               
+
                        // Loading language-labels
                $this->pi_loadLL();
 
@@ -190,6 +190,7 @@ class tx_felogin_pi1 extends tslib_pibase {
                $markerArray['###FORGOT_PASSWORD_ENTEREMAIL###'] = $this->pi_getLL('forgot_password_enterEmail', '', 1);
                $markerArray['###FORGOT_EMAIL###'] = $this->prefixId.'[forgot_email]';
                $markerArray['###SEND_PASSWORD###'] = $this->pi_getLL('send_password', '', 1);
+               $markerArray = array_merge($markerArray, $this->getUserFieldMarkers());
 
                return $this->cObj->substituteMarkerArrayCached($subpart, $markerArray, $subpartArray, $linkpartArray);
        }
@@ -213,7 +214,8 @@ class tx_felogin_pi1 extends tslib_pibase {
                $markerArray['###STORAGE_PID###'] = $this->spid;
                $markerArray['###USERNAME###'] = htmlspecialchars($GLOBALS['TSFE']->fe_user->user['username']);
                $markerArray['###USERNAME_LABEL###'] = $this->pi_getLL('username', '', 1);
-               
+               $markerArray = array_merge($markerArray, $this->getUserFieldMarkers());
+
                if ($this->redirectUrl) {
                                // use redirectUrl for action tag because of possible access restricted pages
                        $markerArray['###ACTION_URI###'] = $this->redirectUrl;
@@ -237,7 +239,8 @@ class tx_felogin_pi1 extends tslib_pibase {
                        if($this->userIsLoggedIn) {
                                        // login success
                                $markerArray['###STATUS_HEADER###'] = $this->getDisplayText('success_header',$this->conf['successHeader_stdWrap.']);
-                               $markerArray['###STATUS_MESSAGE###'] = str_replace('###USER###',htmlspecialchars($GLOBALS['TSFE']->fe_user->user['username']),$this->getDisplayText('success_message',$this->conf['successMessage_stdWrap.']));
+                               $markerArray['###STATUS_MESSAGE###'] = $this->getDisplayText('success_message', $this->conf['successMessage_stdWrap.']);
+                               $markerArray = array_merge($markerArray, $this->getUserFieldMarkers());
                                $subpartArray['###LOGIN_FORM###'] = '';
 
                                        // Hook for general actions after after login has been confirmed (by Thomas Danzl <thomas@danzl.org>)
@@ -298,6 +301,7 @@ class tx_felogin_pi1 extends tslib_pibase {
                $markerArray['###STORAGE_PID###'] = $this->spid;
                $markerArray['###USERNAME_LABEL###'] = $this->pi_getLL('username', '', 1);
                $markerArray['###REDIRECT_URL###'] = $this->redirectUrl;
+               $markerArray = array_merge($markerArray, $this->getUserFieldMarkers());
 
                if ($this->flexFormValue('showForgotPassword','sDEF') || $this->conf['showForgotPasswordLink']) {
                        $linkpartArray['###FORGOT_PASSWORD_LINK###'] = explode('|',$this->getPageLink('|',array($this->prefixId.'[forgot]'=>1)));
@@ -601,7 +605,28 @@ class tx_felogin_pi1 extends tslib_pibase {
         * @return      string          label text
         */
        protected function getDisplayText($label, $stdWrapArray=array()) {
-               return $this->flexFormValue($label,'s_messages') ? $this->cObj->stdWrap($this->flexFormValue($label,'s_messages'),$stdWrapArray) : $this->cObj->stdWrap($this->pi_getLL('ll_'.$label, '', 1), $stdWrapArray);
+               $text = $this->flexFormValue($label, 's_messages') ? $this->cObj->stdWrap($this->flexFormValue($label, 's_messages'), $stdWrapArray) : $this->cObj->stdWrap($this->pi_getLL('ll_'.$label, '', 1), $stdWrapArray);
+               $replace = $this->getUserFieldMarkers();
+               return strtr($text, $replace);
+       }
+
+       /**
+        * Returns Array of markers filled with user fields
+        *
+        * @return      array           marker array
+        */
+       protected function getUserFieldMarkers() {
+               $marker = array();
+               // replace markers with fe_user data
+               if ($GLOBALS['TSFE']->fe_user->user) {
+                       // all fields of fe_user will be replaced, scheme is ###FEUSER_FIELDNAME###
+                       foreach ($GLOBALS['TSFE']->fe_user->user as $field => $value) {
+                               $marker['###FEUSER_' . t3lib_div::strtoupper($field) . '###'] = $this->cObj->stdWrap($value, $this->conf['userfields.'][$field . '.']);
+                       }
+                       // add ###USER### for compatibility
+                       $marker['###USER###'] = $marker['###FEUSER_USERNAME###'];
+               }
+               return $marker;
        }
 }