I have modified the existing code for this module to provide an alternate UI to modify the privacy field settings for a user profile. I also extended the functionality to allow for more options than just private versus public. I currently just have public, authenticated and private. I will create a UI to select more roles.

I believe this functionality could be useful to other people. I appreciate Boobaa's work on this, but the default functionality of the module was insufficient for my needs. I would like to give back my extensions to the community.

Comments

dpalmer’s picture

Patch

dpalmer’s picture

Issue summary: View changes
dpalmer’s picture

dpalmer’s picture

Issue summary: View changes
dpalmer’s picture

Status: Active » Needs review
erwangel’s picture

Excellent! Exactly what I was looking for. And it works !
Here are some suggestions for improvement :

1) Default value is set by _user_field_privacy_value which looks for it in the database or returns nothing. If user doesn't set one in all fields, there is an sql error while validating the settings page.
My (dirty) changes in user_field_privacy_settings_form():

	  if (_user_field_privacy_value($instance['field_id'], $account->uid) != '') {
	    $default_privacy = _user_field_privacy_value($instance['field_id'], $account->uid); 
	  } else {
	    $default_privacy = 2; // default to Authenticated users
	  }
			
      $field_name = $instance['field_name'];
      $form[$field_name]['user_field_privacy_' . $field_name] = array(
        '#type' => 'radios',
        '#title' => check_plain($instance['label']),
        '#options' => $privacy,
//        '#default_value' =>  _user_field_privacy_value($instance['field_id'], $account->uid),
        '#default_value' => $default_privacy,
        '#required' => TRUE,
      );

2) User roles are hardcoded in user_field_privacy_settings_form() and user_field_privacy_field_access(). This way only the two core values are processed (1 = anonymous/public and 2=authenticated, 0=private)
$privacy = array(0 => t('Private'), 2 => t($member_role->name), 1 => t('Public'));
a) admin cannot set the privacy settings to a given user. There is no "Edit Privacy Settings" tab/button and if you try to access to [site.com]/users/[user_id]/edit/privacy as admin you get an "access denied / not authorized to access this page"
b) if you have more than the core roles, they will not appear in the settings choice
Possible solution: request the available roles in the database and rebuild the above line according to dbquery results

dpalmer’s picture

Thanks erwangel, I will implement those fixes and a few others this weekend.

erwangel’s picture

Cool!

dpalmer’s picture

patch

dpalmer’s picture

I apologize for the delay, I have been busy transitioning my employment.

Anyways, here is a patch with the suggested changes and improvements. Please test.

apmsooner’s picture

Status: Needs review » Needs work

Can't get that patch to apply cleanly.

Fails at line 106 for me.

apmsooner’s picture

Status: Needs work » Reviewed & tested by the community

Sorry for previous post. I didn't initially apply the patch against dev branch. I tried that and it applied cleanly. The revised interface is a great improvement! Not sure about the "authenticated user" option however as my existing users might not know what exactly that means but... i can live with it.

apmsooner’s picture

Status: Reviewed & tested by the community » Needs work

Found some issues:
1. Need an "Access User Field Privacy Settings for all users" permission. Otherwise, only the user can edit their privacy settings. Looks like there is a permission "Access private fields" but its set under the field permissions module. Maybe thats the issue i'm seeing and in line with https://www.drupal.org/node/1559460
2. If no fields are set for privacy settings, the tab on edit user profile still shows and this error appears on page load:
Notice: Undefined variable: user_field_privacy in user_field_privacy_settings_form()
3. If a field is set for privacy settings, no other user other than administrator can view the field regardless of the setting. If set to public, it should be public to all users... it currently isn't obeying the default value on install. It appears however to set when the user edits their privacy settings though and saves so i think the issue is there is no value being set initially in the database perhaps which means null means hide.

apmsooner’s picture

Tried the patch in #1.... still get access denied to other users privacy settings as admin.