I have a site where some users have email accounts on the site's server, but most do not. Yet any user who viewsto his/her account page sees "Domain administrator right: No Domains." if that user does not have an account managed by Mailfix and does not have authority to maintain such accounts. Only a few people have such authority. For the bulk of users the Mailfix information is irrelevant and makes them ask the question: "what does this mean?"

It would be very nice if Mailfix tested to see whether a user has a mailbox it manages or the user has authority to administer mailboxes on the domain and display information only if one or both condition are true.

The fix appears to be in the following code at the end of the mailfix_admin.module. But I'm no php expert and couldn't figure out exactly what to do.

/**
 * Inject mailfix information when user's info is being displayed.
 *
 * @param object $account
 *    User object passed by reference.
 */
function mailfix_admin_view_user(&$account) {
  $access_level = mailfix_admin_get_access_level('view', $account);

  if ($access_level < MAILFIX_ADMIN_ACCESS_READONLY_ADMIN_FIELDS)
    return;

  $admin_for = mailfix_admin_get_current_dom_list($account, '');

  $account->content['mailfix']['admin_info'] = array(
    '#type' => 'user_profile_item',     // another core themable hook
    '#title' => 'Domain administration rights',
    '#weight' => 5,
    '#value' => $admin_for ? $admin_for : t('No domains.'),
    );
  
} // mailfix_admin_view_user

function mailfix_admin_create_user_block() {
  global $user;

  $domains = mailfix_admin_get_current_dom_list($user, '');

  // Can the current user create users?
  if ($domains == '' && !($user->uid == 1 || user_access('administer users')))
    return NULL;

  $block['subject'] = t('Mailfix Admin Create User');
  $block['content'] = drupal_get_form('mailfix_admin_create_user_form');
  return $block;
}

function mailfix_admin_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $blocks[0]['info'] = t('Mailfix Admin Create User');
      $blocks[0]['cache'] = BLOCK_CACHE_PER_USER;
      return $blocks;
    case 'view':
      switch ($delta) {
        case 0:
          return mailfix_admin_create_user_block();
          break; 
      }
      break;
  }
}

Comments

nigelcunningham’s picture

Thanks for the report.

Fixed in commit 5b70a2e08e49d11358b86921a8ed6efb77f5e025.

nigelcunningham’s picture

Status: Active » Fixed
rsbecker’s picture

Nigel

Thanks for the fixes. They are working very well. This is a very helpful module.

nigelcunningham’s picture

Does that include the one I marked as 'needs review'? If so, I'll commit it too.

rsbecker’s picture

I posted that in November, when I was still using D6.19. I am now using D6.20. I have not seen that problem in several months. I may have solved that problem by commenting out that line in the module, but I don't recall. Bottom line is I am not having that problem anymore.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.