I cleaned up the utility bar code. I looked through the code because I want to enable the utility bar only for certain rules. So I needed to change the the module to use drupals user_access function. I found some more stuff that was not needed so I cleaned the module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

osopolar’s picture

ADD utility_bar_perm(): adds the 'access utility_bar' permission
CAHNGE utility_bar_admin(); remove $form['utility_bar_display'] and $form['utility_bar_display_anon']
CAHNGE utility_bar_init(): use user_acces(). I guess there will be no performance hit, because user_acces has a static vars cache and I am sure it will be called also by other modules hook_init.
ADD utility_bar_update_6001(): to set permissions
REMOVE utility_bar_preprocess_utility_bar(): no need for an empty function.
REMOVE _utility_bar_display_utility_bar(): no need for this: in the js thevariables 'display_anon' and 'user_logged_in' aren't used and the visibility is done by user_acces('access utility_bar');

Less related changes:

CHANGE utility_bar.tpl.php: use utility_bar_messages_header instead of wh_utility_bar_messages_header
CHANGE _utility_bar_container(): if (1) is alway true.
REMOVE $Id$ Tags
REMOVE define(): None of them will be used anymore
REMOVE Whitespaces
ADD Comments

wjackson’s picture

Using Drupal's permission system is a must! While attempting to apply this patch I got this:

Hunk #1 FAILED at 27.
1 out of 1 hunk FAILED -- saving rejects to file b/theme/utility_bar.tpl.php.rej
patching file b/utility_bar.admin.inc
Hunk #1 FAILED at 14.
1 out of 1 hunk FAILED -- saving rejects to file b/utility_bar.admin.inc.rej
patching file b/utility_bar.info
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file b/utility_bar.info.rej
patching file b/utility_bar.install
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 47.
2 out of 2 hunks FAILED -- saving rejects to file b/utility_bar.install.rej
patching file b/utility_bar.module
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 21.
Hunk #3 FAILED at 37.
Hunk #4 FAILED at 100.
Hunk #5 FAILED at 127.
Hunk #6 FAILED at 147.
Hunk #7 FAILED at 157.
Hunk #8 FAILED at 198.
8 out of 8 hunks FAILED -- saving rejects to file b/utility_bar.module.rej

osopolar’s picture

Status: Needs review » Active

I tried both versions of ub 6.x-1.0-beta3 and 6.x-1.x-dev. Both are working.

download the patch to the modules folder, cd in utility_bar and try:

patch -p1 --dry-run < ../utility_bar-permissions-1268606-1.patch
osopolar’s picture

Status: Active » Needs review
osopolar’s picture

Version: 6.x-1.0-beta3 » 6.x-1.x-dev
Status: Active » Needs review