--- W:/ClearlyByDesign/Drupal/modules/6.x/alterprofilepage/6.x-2.6/alterprofilepage/alterprofilepage.module Sun Apr 04 04:43:54 2010 +++ W:/ClearlyByDesign/Drupal/modules/6.x/alterprofilepage/6.x-2.6 patched/alterprofilepage/alterprofilepage.module Fri Aug 27 09:34:27 2010 @@ -46,10 +46,113 @@ $lastlogintime = strftime('%x', $account->access); } $account->content['summary']['last_access'] = array( - '#type' => 'user_profile_item', - '#title' => t('Last login'), - '#value' => $lastlogintime, - '#weight' => -18, + '#type' => 'user_profile_item', + '#title' => t('Last login'), + '#value' => $lastlogintime, + '#weight' => -18, ); - drupal_set_title(t('@user\'s profile', array('@user' => $account->name))); + + $title_pattern = t( variable_get( 'alterprofilepage_title', t( '@user\'s profile' ) ), + array( '@user' => $account->name, ) ); + + if ( module_exists ( 'token' ) ) { + + $types = array( + 'global' => NULL, + 'user' => user_load( $account->uid ), + ); + + // Apply token patterns by resetting the token cache first and then using token_replace_multiple to insert token values + token_get_values( 'global', NULL, TRUE ); + $title = token_replace_multiple( $title_pattern, $types ); + + // Extra fields + $extra = variable_get( 'alterprofilepage_extras', '' ); + if ( !empty( $extra ) ) { + $extras_lines = preg_split( '[\n]', str_replace( array( '\r\n', '\r' ), '\n', $extra ) ); + foreach ( $extras_lines as $extra_item => $line ) { + $extra_field = explode( '|', $line, 3 ); // label|class|value, where type is either 'item' or 'markup' + $extra_field[1] = trim( $extra_field[1] ); + $account->content['summary']['alterprofilepage_extra_' . $extra_item] = array( + '#type' => 'user_profile_item', + '#title' => filter_xss( token_replace_multiple( t( $extra_field[0] ), $types ) ), + '#attributes' => ( !empty( $extra_field[1] ) ? array( 'class' => filter_xss( token_replace_multiple( $extra_field[1], $types ) ), ) : array() ), + '#value' => filter_xss( token_replace_multiple( $extra_field[2], $types ) ), + '#weight' => -17 + $extra_item, + ); + } + } + + } + else { + $title = $title_pattern; + } + + drupal_set_title( filter_xss( $title ) ); + +} + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function alterprofilepage_form_user_admin_settings_alter(&$form, $form_state) { + + $form['alterprofilepage_title_fldset'] = array( + '#type' => 'fieldset', + '#title' => t( 'Profile Page Title' ), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); + + $form['alterprofilepage_title_fldset']['alterprofilepage_title'] = array( + '#type' => 'textarea', + '#title' => t( 'Title pattern' ), + '#description' => t( 'You can specify a pattern to be used for the user + profile page title instead of the default pattern. + Use @user as a token for the user name.' ), + '#default_value' => variable_get( 'alterprofilepage_title', t( '@user\'s profile' ) ), + '#rows' => 2, + ); + + if ( module_exists( 'token' ) ) { + // Add the token help to a collapsed fieldset at the end of the configuration page. + + $form['alterprofilepage_title_fldset']['alterprofilepage_title']['#description'] .= + ' ' . t( 'You can also use other tokens in the pattern (see Available Token List below).' ); + + $form['alterprofilepage_title_fldset']['token_help'] = array( + '#type' => 'fieldset', + '#title' => t('Available Tokens List'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['alterprofilepage_title_fldset']['token_help']['content'] = array( + '#type' => 'markup', + '#value' => theme('token_help'), + ); + + $form['alterprofilepage_extras'] = array( + '#type' => 'textarea', + '#title' => t( 'Extras' ), + '#description' => t( 'You can specify extra fields to be displayed in the summary area of + the profile here. Use a separate line for each field with each + line inthe format

    + title|classes|value

+ where + Extra fields will appear in the order you specify them here.' ), + '#default_value' => variable_get( 'alterprofilepage_extras', '' ), + '#rows' => 5, + ); + + } + }