I guess firstly I'm not entirely sure I understand what the settings are controlling. For instance, I have the following code:

function mymodule_block_permission() {
  return array(
    'administer mymodule header block' => array(
      'title' => t('Administer mymodule Header Block Settings'),
    ),
  );
}

function mymodule_block_variable_info($options = array()) {
  $variable = array();
  $variable['mymodule_block_header_contact'] = array(
    'type' => 'string',
    'title' => t('mymodule Header Contact Message', array(), $options),
    'description' => t('The text to display in the header contact block.'),
    'default' => 'call us: 555 555 5555',
    'group' => 'mymodule_header_settings',
  );
  return $variable;
}

function mymodule_block_variable_group_info() {
  $groups = array();
  $groups['mymodule_header_settings'] = array(
    'title' => t('mymodule Header Settings'),
    'description' => t('Configure settings relating to the mymodule Header.'),
    'access' => 'administer mymodule header block',
    'admin' => array('admin/mymodule/header'),
  );
  return $groups;
}

My confusion is that users given the permission 'administer mymodule header block' are still unable to view the variable settings page, either on:

- http://localhost/admin/config/system/variable/group/mymodule_header_sett...

... which would be default, or:

- http://localhost/admin/mymodule/header

... as defined in the hook_variable_group_info.

1) FIrstly, I don't understand why the 'access' setting set in hook_variable_group_info is being ignored, or denied by another permission.

2) Nor do I understand the purpose of the 'admin' setting, I'm not defining the page anywhere else such as via hook_menu.

Thanks for any clarification!

Comments

jose reyero’s picture

Status: Active » Fixed

Pages generated by variable admin need the 'administer site configuration' permission. About the module page, it will have its own permission too to acess the page, then will check for permissions for each of the variables in the page.

The admin setting is not used anywhere yet but the idea is to provide information about where each variable / group can be edited.

Status: Fixed » Closed (fixed)

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

jeni_dc’s picture

Sorry to reopen and if there's overlap with i18n_variable module, but I don't fully understand what you're saying regarding the permissions.

I'm using a custom form in my module with system_settings_form() to set multilingual variables. I've created a group for the variables like so:

function my_module_variable_group_info() {
  $groups['my_module_group'] = array(
    'title' => t('My Module Vars'),
    'description' => t("Variables for my module."),
    'access' => 'my module custom permission',
    'path' => array('admin/my-module'),
  );
  return $groups;
}

Access to "/admin/my-module" is controlled from the same "my module custom permission" permission in a hook_menu(). When on that page, users with a role that have the assigned "my module custom permission" cannot see any of the translations. But if I grant them the "administer site configuration" they can.

1) Is this an issue with access from Variable module, or is i18n_variable responsible for this? (I can't see where it would be i18n_variable).

2) How do I allow my users to edit these multilingual variables without granting them the "administer site configuration" permission?

You mentioned:

About the module page, it will have its own permission too to acess the page, then will check for permissions for each of the variables in the page.

My module page does have it's own permission. And if I explicitly set access on each of the variables to "my module custom permission" they still can only edit the English vars.

jeni_dc’s picture

In doing a bit more research I saw where the variables are being switched per realm in variable_realm_init().

function variable_realm_init() {
  if (arg(0) == 'admin' && (arg(3) != 'variable' || arg(4) != 'realm') && ($params = variable_realm_params()) && user_access('administer site configuration')) {
    foreach ($params as $realm_name => $realm_key) {
      variable_realm_switch($realm_name, $realm_key, FALSE);
    }
    variable_realm_rebuild();
  }
}

It's that user_access('administer site configuration') which is causing my problems since I don't want to give that out to this specific user role. My solution is to add my own hook init and check for my custom admin path and permission:

function my_module_init() {
  if (arg(0) == 'admin' && arg(1) == 'my-module' && ($params = variable_realm_params()) && user_access('my module custom permission')) {
    foreach ($params as $realm_name => $realm_key) {
      variable_realm_switch($realm_name, $realm_key, FALSE);
    }
    variable_realm_rebuild();
  }
}