# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. --- administrator/components/com_comprofiler/plugin.foundation.php +++ administrator/components/com_comprofiler/plugin.foundation.php @@ -1181,28 +1181,8 @@ $msg = $this->_evaluateIfs( $msg ); $msg = $this->_evaluateCbTags( $msg ); + $msg = $this->_evaluateCbFields( $msg ); - if ( is_object( $row ) ) { - // old legacy modes: - $array = get_object_vars( $row ); - foreach( $array AS $k => $v ) { - if( ( ! is_object( $v ) ) && ( ! is_array( $v ) ) ) { - if ( ! ( ( strtolower( $k ) == "password" ) && ( strlen($v) >= 32 ) ) ) { - /* do not translate content ! : - $vTranslated = ( $translateLanguage ? getLangDefinition( $v ) : $v ); - if ( is_array( $htmlspecialchars ) ) { - $vTranslated = call_user_func_array( $htmlspecialchars, array( $vTranslated ) ); - } - $msg = cbstr_ireplace("[".$k."]", $htmlspecialchars === true ? htmlspecialchars( $vTranslated ) : $vTranslated, $msg ); - */ - if ( is_array( $htmlspecialchars ) ) { - $v = call_user_func_array( $htmlspecialchars, array( $v ) ); - } - $msg = cbstr_ireplace("[".$k."]", $htmlspecialchars === true ? htmlspecialchars( $v ) : $v, $msg ); - } - } - } - } foreach( $extraStrings AS $k => $v) { if( ( ! is_object( $v ) ) && ( ! is_array( $v ) ) ) { /* do not translate content ! : @@ -1499,6 +1479,38 @@ return preg_replace_callback( $regex, array( $this, '_evaluateIfs' ), $input ); } + function _evaluateCbFields( $input ) { + $regex = '#\[([\w-]+)\]#'; + + if ( is_array( $input ) ) { + if ( ( $this !== null ) && is_object( $this->_cbuser ) && isset( $this->_cbuser->id ) ) { + $val = $this->getField( $input[1], null, 'php' ); + + if ( is_array( $val ) || isset( $this->_cbuser->$input[1] ) ) { + if ( is_array( $val ) ) { + $val = array_shift( $val ); + } + + if ( ! $val ) { + $val = $this->_cbuser->get( $input[1] ); + } + + if( ( ! is_object( $val ) ) && ( ! is_array( $val ) ) ) { + if ( ! ( ( strtolower( $input[1] ) == 'password' ) && ( strlen( $val ) >= 32 ) ) ) { + return $val; + } + } + } else { + return '[' . $input[1] . ']'; + } + } else { + return '[' . $input[1] . ']'; + } + } + + return preg_replace_callback( $regex, array( $this, '_evaluateCbFields' ), $input ); + } + function _evaluateCbTags( $input ) { global $_CB_framework; @@ -1514,7 +1526,17 @@ switch ( $type ) { case 'userdata': - return $user->_cbuser->get( $input[2] ); + $val = $user->getField( $input[2], null, 'php' ); + + if ( is_array( $val ) ) { + $val = array_shift( $val ); + } + + if ( ! $val ) { + $val = $user->_cbuser->get( $input[2] ); + } + + return $val; break; case 'userfield': case 'usertab':