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.
| Attachment | Size |
|---|---|
| i18n.inc.diff | 1.06 KB |

#1
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
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
#4
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!
#5
This looks very good.
Committed the patch in #4 with a small change to allow node load caching to work.
Thanks
#6
Automatically closed -- issue fixed for two weeks with no activity.