Specific permissions -access control- for translations

fsimo - December 18, 2005 - 08:10
Project:Internationalization
Version:5.x-2.x-dev
Component:Code
Category:feature request
Priority:critical
Assigned:Unassigned
Status:closed
Description

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.

AttachmentSize
i18n.inc.diff1.06 KB

#1

rblomme - April 7, 2006 - 17:39

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;
}

#2

Jose A Reyero - August 5, 2006 - 16:24
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...

#3

Jose A Reyero - August 5, 2006 - 16:35
Title:Specific 'access controls' for transaltion» Specific permissions -access control- for translations

#4

christopher_skauss - February 6, 2008 - 14:52
Version:4.7.x-1.x-dev» 5.x-2.x-dev
Status:active» patch (code needs review)

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!

AttachmentSize
translation.module.patch1.61 KB

#5

Jose A Reyero - April 28, 2008 - 12:00
Status:patch (code needs review)» fixed

This looks very good.

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

Thanks

#6

Anonymous (not verified) - May 12, 2008 - 12:01
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.