Index: modules/translation/translation.module =================================================================== RCS file: /cvs/drupal/drupal/modules/translation/translation.module,v retrieving revision 1.46 diff -u -p -r1.46 translation.module --- modules/translation/translation.module 27 May 2009 18:34:02 -0000 1.46 +++ modules/translation/translation.module 31 May 2009 10:19:05 -0000 @@ -75,8 +75,10 @@ function translation_menu() { * all languages). */ function _translation_tab_access($node) { + global $user; + if (!empty($node->language) && translation_supported_type($node->type)) { - return user_access('translate content'); + return (user_access('translate content') || (($node->uid == $user->uid) && user_access('translate own content'))); } return FALSE; } @@ -90,6 +92,10 @@ function translation_perm() { 'title' => t('Translate content'), 'description' => t('Translate website content.'), ), + 'translate own content' => array( + 'title' => t('Translate own content'), + 'description' => t('Translate own website content.'), + ), ); } @@ -111,6 +117,8 @@ function translation_form_node_type_form * is about to be created. */ function translation_form_alter(&$form, &$form_state, $form_id) { + global $user; + if (isset($form['#id']) && $form['#id'] == 'node-form' && translation_supported_type($form['#node']->type)) { $node = $form['#node']; if (!empty($node->translation_source)) { @@ -133,7 +141,7 @@ function translation_form_alter(&$form, $form['translation'] = array( '#type' => 'fieldset', '#title' => t('Translation settings'), - '#access' => user_access('translate content'), + '#access' => user_access('translate content') || (($node->uid == $user->uid) && user_access('translate own content')), '#collapsible' => TRUE, '#collapsed' => !$node->translate, '#tree' => TRUE, @@ -193,11 +201,13 @@ function translation_node_view($node, $t * Implement hook_node_prepare(). */ function translation_node_prepare($node) { + global $user; + // Only act if we are dealing with a content type supporting translations. if (translation_supported_type($node->type)) { if (empty($node->nid) && isset($_GET['translation']) && isset($_GET['language']) && ($source_nid = $_GET['translation']) && ($language = $_GET['language']) && - (user_access('translate content'))) { + (user_access('translate content') || (($node->uid == $user->uid) && user_access('translate own content')))) { // We are translating a node from a source node, so // load the node to be translated and populate fields. $source_node = node_load($source_nid); Index: modules/translation/translation.test =================================================================== RCS file: /cvs/drupal/drupal/modules/translation/translation.test,v retrieving revision 1.11 diff -u -p -r1.11 translation.test --- modules/translation/translation.test 2 Apr 2009 20:39:45 -0000 1.11 +++ modules/translation/translation.test 31 May 2009 10:19:05 -0000 @@ -23,6 +23,7 @@ class TranslationTestCase extends Drupal // Setup users. $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages')); $translator = $this->drupalCreateUser(array('create page content', 'edit own page content', 'translate content')); + $own_translator = $this->drupalCreateUser(array('create page content', 'edit own page content', 'translate own content')); $this->drupalLogin($admin_user); @@ -82,6 +83,13 @@ class TranslationTestCase extends Drupal $edit['translation[status]'] = FALSE; $this->drupalPost('node/' . $node_translation->nid . '/edit', $edit, t('Save')); $this->assertRaw(t('Page %title has been updated.', array('%title' => $node_translation_title)), t('Translated node updated.')); + + $this->drupalLogout(); + $this->drupalLogin($own_translator); + + // Attempt to translate a node which has not been created by the user. + $this->drupalGet('node/' . $node->nid . '/translate'); + $this->assertResponse(403); } /**