Information about '%count reads' in node's footer is shown to unprivileged users. I suggest that function statistics_link in statistics.module should be corrected in this way:
// Original
function statistics_link($type, $node = 0, $main = 0) {
global $id;
$links = array();
if ($type != 'comment' && variable_get('statistics_display_counter', 0)) {
$statistics = statistics_get($node->nid);
if ($statistics) {
$links[] = format_plural($statistics['totalcount'], '1 read', '%count reads');
}
}
return $links;
}
// Fixed
function statistics_link($type, $node = 0, $main = 0) {
global $id;
$links = array();
if ($type != 'comment' && variable_get('statistics_display_counter', 0) && user_access('display statistics')) {
$statistics = statistics_get($node->nid);
if ($statistics) {
$links[] = format_plural($statistics['totalcount'], '1 read', '%count reads');
}
}
return $links;
}
The only change is in "&& user_access('display statistics')" on line 98.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | stat_counter_permission.HEAD.patch | 3.04 KB | robin monks |
| #18 | node_counter_permission.patch | 2.97 KB | robin monks |
| #12 | authstats_2.patch | 1.11 KB | robin monks |
| #11 | authstats_1.patch | 1.06 KB | robin monks |
| #10 | authstats_0.patch | 1 KB | robin monks |
Comments
Comment #1
RobRoy commentedShould read
user_access('access statistics')notuser_access('display statistics').Comment #2
robin monks commentedAnd here that is in patch form.
Robin
Comment #3
Steven commentedI'm not sure about this patch: often, read counts are shown directly on the site. But if the permission for viewing the counts is the same as the permission for accessing the administrator's detailed logs, then you wouldn't give that to everyone.
There is already an option to choose whether counts are displayed. Perhaps we could change that to "No" "For priviledged users" "For everyone". In last case it acts like it is now, it the second case it requires "access statistics" permission.
What do you think?
Comment #4
robin monks commentedSounds good to me. I'll try to code something up for this.
Robin
Comment #5
robin monks commentedHere is the patch. Uses a switch to choose between signed in users, all users, users with permissions or noone.
Robin
Comment #6
robin monks commentedI tested this patch with various settings on my local install and it worked fine.
Robin
Comment #7
Bèr Kessels commentedIs there a reason why you check for $user->uid?
Whaen someone has "access statistics" set to anonymous users, your check for $user->uid will override taht settings. Not good IMO.
is very inconsistent. please use *only* the permissions page to set permissions, and do not create new permissions-alike settings in any configuration pages.
I would say a simple check for
user_access('access statistics')will do the trickComment #8
Bèr Kessels commentedsorry, i meant to say
user_access('access statistics counter'), notuser_access('access statistics').We already have "access statistics'" an additional "access statistics counter" for showing users the counter should work
Ber
Comment #9
robin monks commentedOK, here is a patch to that end...
Robin
Comment #10
robin monks commentedUm, let's just pretend I didn't just upload the entire stats module. OK? OK!
Robin
Comment #11
robin monks commentedHotfix.
Robin
Comment #12
robin monks commentedHopefuly the final version. Thanks to chx and berkes for pulling it apart ;-)
Robin
Comment #13
Bèr Kessels commented+1 for this patch. it adds functionality, but does not add clutter nor any config options.
Comment #14
frjo commented+1 I have implemented the patch authstats_2.patch on my site running Drupal 4.6.1 and it works well.
Comment #15
mfb+1
Comment #16
jose reyero commented+1
I tested the patch, works fine, and I'm always for "more options" ;-)
Comment #17
junyor commented+1. Using this on my site now.
Comment #18
robin monks commentedThis patch revision removes the duplicate show counter option from the settings.
Thanks UnConeD!
Robin
Comment #19
dries commented-1, the term "access statistics counter" doesn't tell me anything. The counters are for posts -- I think that should be reflected in the permission's name. Is this different from the 'Count content views' setting?
Comment #20
robin monks commentedthe term "access statistics counter" doesn't tell me anything. The counters are for posts -- I think that should be reflected in the permission's name.
Suggestions:
view node access counter
view node view counter
access node view counter
view node hit counter
I rather like "view node access counter". Dries, would this satisify you?
Is this different from the 'Count content views' setting?
Yes, on two counts.
Robin
Comment #21
robin monks commentedNew version of patch that renames the permission to "view node access counter".
Tested on latest HEAD. Ready to commit!
Robin
Comment #22
Stefan Nagtegaal commentedVery nice patch! One option less...
Works flawelessly on my localhost... :-)
Comment #23
Steven commentedThis patch did not apply anymore, but it was easy to fix.
Committed to HEAD.
Comment #24
dries commented