When dealing with content_profile nodes, each user has at most one. So that one should be loaded when considering completeness. Please check out attached patch. It loads current user's profile node by default. If the user can edit any node of that type, then: if they are looking at another user account, or their profile node, that node will be loaded. Thus a site admin will see everyone's profile completeness when looking at their profiles.

Also, db_rewrite_sql is not necessary; it breaks one query when a user is looking at their own profile node.

Comments

alex.k’s picture

StatusFileSize
new1.93 KB

Oops, forgot curly braces around table name in the query. If you like the patch, the function should probably be refactored more to pass just node ids into the main loop, not a database result. It would avoid the silly select that I added.

pvhee’s picture

Status: Needs review » Fixed

Thanks for the patch. I committed a light-weight version of your patch to the repository, including support when used with profile nodes. However, it only gives you the complete percentage for the current user. Thus, even if you are admin you only see your own percentage. This is by design for the moment, as I would like to have a clearer approach towards CCK statistics. This module is only for pointing your users (not the admin) to their incomplete nodes.

CCK statistics could be the topic of a new module (or a quite big extension of the current one), in which for example statistics are generated for the CCK nodes of all users. This module could then be made to work with drupal actions/hooks (for example, send an email to the user when the profile is not complete enough), views, and so on.

pvhee’s picture

I am using mysql_db_rewrite following this suggestion: http://drupal.org/node/93737. I can imagine that you might want to restrict access on certain CCK types with this rewrite function.

However, I see that it is causing this bug: #363828: SQL error. How is this possible?

alex.k’s picture

Hmm, the patch just removes db_rewrite_sql (good point about using it, thanks!). So one of the modules that do rewrite must be introducing the join incorrectly. Left a comment in #363828: SQL error, perhaps the poster can try to reproduce.

Status: Fixed » Closed (fixed)

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