I made some modification on i18n.inc to allow me to define transalation access controls.

I thinks it's not the right way to do that, but it's working.

Comments

rblomme’s picture

I have done something similar.

In i18n.module

/**
 * Implementation of hook_perm().
*/
function i18n_perm() {
  return array('translate nodes', 'translate own nodes');
}

/**
 * Implementation of hook_access().
*/
function i18n_access($node) {
        global $user;
        return user_access('translate nodes') || $node->uid == $user->uid && user_access('translate own nodes');
}

In i18n.inc

function i18n_menu($may_cache) {
  $items = array();

  if ($may_cache) {
      $items[] = array(
        'path' => 'admin/taxonomy/i18n',
        'title' => t('translation'),
        'callback' => 'i18n_taxonomy_admin',
        'access' => user_access('administer taxonomy'),
        'type' => MENU_LOCAL_TASK);
  }
  else {
    if (arg(1) == 'node' && is_numeric(arg(2)) ) {
      $node = node_load(array('nid' => arg(2)));
      $access = i18n_access($node);
      $items[] = array(
        'path' => 'translation',
        'title' => t('translation'),
        'callback' => 'i18n_translation_page',
        'access' => $access,
        'type' => MENU_CALLBACK);
    }
    if (arg(0) == 'node' && is_numeric(arg(1)) && variable_get('i18n_node_'.i18n_get_node_type(arg(1)), 0)) {
      $node = node_load(array('nid' => arg(1)));
      $access = i18n_access($node);
      $type = MENU_LOCAL_TASK;
      $items[] = array(
        'path' => 'node/'. arg(1) .'/translation',
        'title' => t('translation'),
        'callback' => 'i18n_node_translation',
        'access' => $access,
        'type' => $type);
    }
  }

  return $items;
}
jose reyero’s picture

Version: 4.6.x-1.x-dev » 4.7.x-1.x-dev

So far I've seem some feature requests asking for more specific 'access control' for translations. The 4.6 version is in maintenance mode, only bug fixes - I don't think it makes sense to add new features that may break existing sites-.

So, if you can agree about some minimum set of permissions, and we have a working patch -for 4.7- I apply it...

jose reyero’s picture

Title: Specific 'access controls' for transaltion » Specific permissions -access control- for translations
chrisroditis’s picture

Version: 4.7.x-1.x-dev » 5.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new1.61 KB

I've made a patch for the 2.x-dev translation.module based on this older patch http://drupal.org/node/69179 that adds the "translate own nodes" permission.

It works for me, hope it helps others too!

jose reyero’s picture

Status: Needs review » Fixed

This looks very good.

Committed the patch in #4 with a small change to allow node load caching to work.

Thanks

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

caktux’s picture

StatusFileSize
new835 bytes

For a user with "Translate own nodes" permission only, creating a translation did not populate the form. I've attached a patch that corrected the issue