The test for the 'view' is not what I would expect.

If I look at someone else's profile, that test will prevent me from seeing his/her profile if I also have 'Address Book' turned on.

I suggest you remove the test of the variable addresses_user_book. (I show it commented out below).

The correct test could be quite complex, and there is not reason to not show the currently logged in user how other users will see his/her profile! (Well... otherwise, if the addresses book is turned on, the feature of showing a user his/her address is automatically turned off which seems to be broken. We could however, have another flag to say whether the user addresses are visible or not in the user profiles.)

// in addresses/addresses_user/addresses_user.module, last function.
/**
 * Implementation of hook_user().
 */
function addresses_user_user($op, &$edit, &$user) {
  if ($op == 'delete') {
    module_load_include('inc', 'addresses_user');
    _addresses_user_address_delete($user->uid, 'user');
  }
  elseif ($op == 'view' /*and !variable_get('addresses_user_book', FALSE)*/) {
    module_load_include('inc', 'addresses_user');
    $addresses = _addresses_user_address_get($user->uid, 'user');
    $address = $addresses[0];
    $user->content['addresses'][] =  array(
      '#type' => 'user_profile_item',
      '#title' => t('Address'),
      '#value' => theme('addresses', $address),
    );
  }
}

Comments

brmassa’s picture

Status: Active » Needs review

Alexis,

if the address book is on it will split the addresses in two places: "main user page" and "address book" and it might no be nice.

But yes, we need to think in a way to store the user preferences about displaying the each field (some users might think its not big deal to show country and state fields only). Note this feature should consider the admins to preset them or let users decide.

regards,

massa

AlexisWilke’s picture

Massa,

Try creating 2 or 3 users. Put a different address for each. Go to user/1, user/2, user/3 (or whatever their numbers are).

If you are logged in as user 2 and go see user 3 profile, you do NOT get the Address Book.

If you are not logged in at all, and check any user profile, you see nothing. No duplicate, that's for sure!

Maybe what you meant was to make the Address Book public? If that's the case, at this time it is "broken".

Thank you.
Alexis

brmassa’s picture

Status: Needs review » Closed (works as designed)

Alexis,

the address book is used is the user wants to record a series of personal addresses, like office address, home, kids' school, friends... its so secret to other users. We might add a "Make the address book public" options, but its a subject to a patch.

regards,

massa