The admin menu has the access callback set to true. This permission is far too broad for any site which has multiple levels of administration. The permission 'administer icons' would be more appropriate.

Comments

systemick’s picture

StatusFileSize
new488 bytes

I've created a patch for this issue

dw72’s picture

Status: Active » Needs review

Works ok with patch #1

dw72’s picture

Category: feature » bug

This is no feature request, this is bug in permissions.

markhalliwell’s picture

Category: bug » feature
Status: Needs review » Needs work

I'm almost tempted to mark this as "closed (works as designed)". The purpose behind granting full access to view the icons is anyone should be able to at least view the icons (ie: say you want to provide documentation to end users and point them to the link that shows them what icons are available).

Other submodules (ie: icon_block, icon_menu) have additional permissions that give you the ability to limit the editing of the icons. I'm not entirely sure what it is you want me to do here.

PS, this is a feature, not a bug (for reasons stated above).

dw72’s picture

Without this patch authenticated users have rights to disable icons bundle or edit and delete it... not only view icons. This must be corrected with this or other way... maybe you need to split this to 'view icons' and 'edit icons' permissions.

markhalliwell’s picture

Category: feature » bug

Ah, well in that case this is a bug after all then. However, the edit and delete links/callbacks are what need the permission then, not the overview form. So the issue/patch needs to reflect that.

dw72’s picture

Yes after your explanation patch must be changed...

dw72’s picture

Status: Needs work » Needs review
StatusFileSize
new3.08 KB

Please check this patch, I think it is working ok, but i'm not too familiar with drupal permission and forms building system and may do some mistakes.

markhalliwell’s picture

Status: Needs review » Needs work
  1. +++ b/includes/admin.inc
    @@ -29,16 +29,27 @@ function icon_bundle_overview_form($form, &$form_state) {
    +    if (user_access('administer icons')) {
    +      $form['bundles'][$bundle['name']]['status'] = array(
    +        '#type' => 'checkbox',
    +        '#default_value' => $bundle['status'],
    +      );
    +    }
    +    else {
    +      $form['bundles'][$bundle['name']]['status'] = array(
    +        '#type' => 'checkbox',
    +        '#disabled' => TRUE,
    +        '#default_value' => $bundle['status'],
    +      );
    +    }
    

    I would rather just not show the checkbox instead. Users could open the inspector and just remove the "disabled" attribute and then (in theory) submit the form (which should also be restricted in the form_submit hook).

  2. +++ b/includes/admin.inc
    @@ -102,25 +113,29 @@ function theme_icon_bundle_overview_form($variables) {
    -    if (!empty($bundle['import'])) {
    -      $operations['delete'] = array(
    -        'title' => '<i class="iconapi-delete"></i>' . t('Delete'),
    -        'href' => ICON_ADMIN_PATH . '/bundle/' . $bundle['name'] . '/delete',
    -        'html' => TRUE,
    -      );
    +      if (user_access('administer icons')) {
    +        $operations['configure'] = array(
    +          'title' => '<i class="iconapi-configure"></i>' . t('Configure'),
    +          'href' => ICON_ADMIN_PATH . '/bundle/' . $bundle['name'] . '/configure',
    +          'html' => TRUE,
    +        );
    +      }
         }
    -    elseif (!empty($bundle['overridden'])) {
    -      $operations['reset'] = array(
    -        'title' => '<i class="iconapi-throbber"></i>' . t('Reset'),
    -        'href' => ICON_ADMIN_PATH . '/bundle/' . $bundle['name'] . '/reset',
    -        'html' => TRUE,
    -      );
    ...
    +      if (!empty($bundle['import'])) {
    +        $operations['delete'] = array(
    +          'title' => '<i class="iconapi-delete"></i>' . t('Delete'),
    +          'href' => ICON_ADMIN_PATH . '/bundle/' . $bundle['name'] . '/delete',
    +          'html' => TRUE,
    +        );
    +      }
    +      elseif (!empty($bundle['overridden'])) {
    +        $operations['reset'] = array(
    +          'title' => '<i class="iconapi-throbber"></i>' . t('Reset'),
    +          'href' => ICON_ADMIN_PATH . '/bundle/' . $bundle['name'] . '/reset',
    +          'html' => TRUE,
    +        );
    +      }
         }
    

    Just wrap the entire thing in a user_access check. Don't break the logic of the elseif.

dw72’s picture

Status: Needs work » Needs review
StatusFileSize
new4.69 KB

Next try. Removed checkboxes, and not showing disabled icon bundles for users without admin permissions. Please review.

dw72’s picture

And?

geodaniel’s picture

I'd say that the icon administration pages shouldn't be visible to people who don't have the 'administer icons' permission.

For example, if I have roles for different levels of administrators (e.g. site administrator, limited administrator), I want to give the limited administrator access to only the things they really need. With most other modules, removing the 'administer [x]' permission will hide the whole menu item for that role rather than just restricting content in it.

That said, I can understand why you want to have it accessible, so perhaps you could add a 'view icon administration' permission as well as the 'administer icons' permission?

geodaniel’s picture

The attached patch combines dw72's patch from #10 and my ideas from #12. An admin can now be given a 'View Icon Information' permission to just view the icons, and can also be given an 'Administer Icons' permission to have the extra control to be able to enable or disable icons, or access other configuration.

geodaniel’s picture

Updated patch which includes form validation handlers to ensure the user has the 'administer icons' permission.

Anonymous’s picture

Either I'm doing something wrong or this patch doesn't actually do anything to the user permissions settings. Ran it, problem with non-admin(custom roles) being able to access Icon config settings persists.

drupov’s picture

Just confirming that the patch from #14 adds the necessary "View Icon Information" permission, which hides the icon information from the roles that do not have it.

The patch was applied against the latest dev of the module (2013-Sep-30).

Thanks!

markhalliwell’s picture

Title: Needs narrower administration permission » Add "view icons" permission and path alias for viewing icons
Category: Bug report » Feature request
Issue summary: View changes
Status: Needs review » Fixed

Thanks guys!

I normally would have given commit attribution, but I had to rework a lot of that patch. Plus I went ahead and added a new feature that let's you set a "path alias" for users with the "view icons" permission. This way it will keep the back end (URL wise) separate.

Committed 76b02fe to 7.x-1.x.

markhalliwell’s picture

Committed b2b4346 to 7.x-1.x.

drupov’s picture

Hi, I have a problem with that one:

granting a user role the "View Icons"-permission gives him the ability to see the URL /icons (or whatever you specify). There he sees the table with the enabled bundles and each row has under Operations only a "View icons"-link. So far so good.

But without the "Administer Icons"-permissions this role cannot access the URL, where the icons for any bundle are listed, e.g. /admin/config/media/icon/bundle/my_bundle ("Access denied"). In fact the "View Icons"-link is something like "icons/my_bundle".

drupov’s picture

Status: Fixed » Needs work
markhalliwell’s picture

Status: Needs work » Fixed

Correct. That is exactly how it's supposed to work. The point of a "view icons" permission (separate from "administer icons") is to create a clear distinction between those who can simply "view" and those who can "administer". The path starts with /admin after all, they shouldn't be going there.

drupov’s picture

Thanks for the quick reply. #21 clarifies this.

I just discovered that the path /icons/my_bundle does work on my Ubuntu development machine when I have no Virtual Host entry for the site, e.g. localhost/drupal_icons/icons/my_bundle.

If I use a VH entry I get a Apache "Not Found" error on drupal_icons.local/icons/my_bundle. The same on the site I develop right now, as well as on the fresh drupal install I am testing icon on.

Does it have something to do with the fact that icons is an aliased path?

markhalliwell’s picture

I run an nginx stack and I'm not seeing this at all. I am seeing it on http://sff120b8134c72a7.s3.simplytest.me/icons/lullacons_pack1. However, when I prepend it with non-clean url query parameter it works: http://sff120b8134c72a7.s3.simplytest.me/?q=icons/lullacons_pack1

I did a little googling and it turns out Apache appears to have an aliases "/icons" path turned on by default:
http://stackoverflow.com/questions/12110693/removal-of-the-var-www-icons...

So the solution is to rename your path alias or just remove that from your configuration.

drupov’s picture

Thanks!

On my Ubuntu machine this settings are written in /etc/apache2/mods-available/alias.conf. I commented them and the /icons/my-bundle path worked.

I have two questions though - and I am happy to buy you beers when we meet, promised :)

1) Isn't is better for the icon module to provide a different default path alias for that page, in order to not conflict with the apache settings?
2) Connected to 1) and probably a bug for this issue - I can change the alias in the icons settings at under "Global settings" at admin/config/media/icon since beta4, which is very cool, but the "View Icons"-link isn't updated. E.g. if I change the View Path Alias to "site-icons" the "View Icons"-link still says "/icons/my_bundle" and not "/site-icons/my-bundle"

markhalliwell’s picture

1) I really don't want to change it, plus it would stop the confusion of other that would also think of such a simple path. So I've committed a warning message: https://drupal.org/comment/8491313#comment-8491313 that only shows up for apache servers and when the path is "icons". The message can also be suppressed.
2) Fixed with https://drupal.org/comment/8491327#comment-8491327

PS, please create new issues for actual bugs. It helps keep track of them instead of in comments.

markhalliwell’s picture

Also, fwiw, I've created 7.x-1.0-beta5 with all these changes (mainly because of the ZIP archive issue with fontello):
https://drupal.org/node/2198473

Status: Fixed » Closed (fixed)

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

  • Commit 76b02fe on 7.x-1.x, icon_tabs-integration by Mark Carver:
    Issue #2075259 by Mark Carver, geodaniel, dw72, systemick: Add "view...
  • Commit b2b4346 on 7.x-1.x, icon_tabs-integration by Mark Carver:
    [#2075259] Fixed view path alias to validate only if the value has...