I am interested in having user statistics only visible to an administrative user. I have set access control so that only the role "Admin" can see user stats: The "View statistics" permission is set for only the Admin role.

I have setup a list view that allows the Admin to see the stats - that works great!

BUT, I am having a problem when non-Admins click the Edit tab on their own profile. The result is an empty form with the "Submit" button only. (Image attached.) (URI for the edit form: user/3/edit/Statistics)

I am not sure what the function of an Edit Statistics form is supposed to be, but I want it removed.

In trying to track down what was creating this menu item, I disabled the User Stats module - it still appeared. I then disabled the Profile core module and then it disappeared.

If there isn't an immediate bug fix for this, is there a work around I can get so I may suppress the menu item?

Comments

liam mcdermott’s picture

Status: Active » Postponed

Unfortunately this was a lame design decision I made when first creating modules. The next major version (probably going to be six only) will not use profile.module. There doesn't seem to be a way to suppress the menu item, I tried renaming the category of the profile field to 'Account settings' and just end up with two 'Account settings' tabs.

The only workaround is to create some visible profile fields in a category like 'Profile', then change the category of the fields created by user stats to the category used by those other fields, e.g. change the user stats field categories to 'Profile'.

Another possibility, I haven't tried this however, is to open up user_stats.info and remove the dependency line. Then disable (but don't uninstall) profile.module

capellic’s picture

Thanks for addressing this and giving me workarounds.

I had wondered why you were leaning on Profile and didn't just use CCK fields for your stat fields or maybe some other way. Good to know that you'll be removing this dependency in the future.

As for another work around .. is it possible to override an object var to remove the Statistics menu item so it's not knowingly accessible? I just don't know where to look for that sort of thing.

liam mcdermott’s picture

I've just tried a couple of things: hook_profile_alter and setting the Category field blank in the database, the former doesn't help and the latter creates a blank tab. On some themes blank tabs are almost invisible and don't load a blank form though, so this might work for you.

That's all I can suggest for the moment. :(

capellic’s picture

Version: 5.x-1.x-dev » 5.x-1.0-beta2

Another possibility, I haven't tried this however, is to open up user_stats.info and remove the dependency line. Then disable (but don't uninstall) profile.module

This doesn't work. I get this error when viewing several user related pages

PHP Fatal error: Call to undefined function profile_load_profile()

capellic’s picture

StatusFileSize
new18.73 KB
new9.44 KB

Here's another idea for a hack. I already had a form_hook_alter module, so I added this switch:

case 'user_edit':

  if ($form['_category']['#value'] == 'Statistics')
  {
    unset($form['submit']);
    unset($form['delete']);
    
    if (isset($form['Statistics'])) {
      foreach ($form['Statistics'] as $k => $v) {
        if (is_array($v)) {
          if ($v['#type'] == 'textfield') {
            $form['Statistics'][$k]['#disabled'] = true;
            $form['Statistics'][$k]['#description'] = 'Field not editable.';
          }
        }
      }
    }
  }
  
  break;

This results in a blank tab for the user and a tab with disabled fields for the admin - both examples are attached.

liam mcdermott’s picture

Good idea, I've committed a version of this. Thanks. :)

Also added a little message for non-admin users, so they don't just get to see a blank screen. Let me know if that text is alright. As usual the changes should be in the dev version (generated at 12:00am and pm GMT), I'll let you--and whoever else wants to--test before creating another beta.

liam mcdermott’s picture

Status: Postponed » Fixed

This is fixed as best as it ever will be in Drupal 5 (unless someone provides patches or money to make it otherwise!) and we no longer use profile.module for storage in the Drupal 6 version.

Marking as fixed.

Status: Fixed » Closed (fixed)

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