|
@@ -106,6 +106,42 @@ function materio_translator_permission() {
|
|
'description' => t('administer user translation language access'),
|
|
'description' => t('administer user translation language access'),
|
|
'restrict access' => TRUE,
|
|
'restrict access' => TRUE,
|
|
),
|
|
),
|
|
|
|
+ 'access_translations_overview' => array(
|
|
|
|
+ 'title' => t('Access translations overview')
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ 'access_translation_table_fields' => array(
|
|
|
|
+ 'title' => t('Access translation Fields table')
|
|
|
|
+ ),
|
|
|
|
+ 'access_translation_table_content_type' => array(
|
|
|
|
+ 'title' => t('Access translation Content types table')
|
|
|
|
+ ),
|
|
|
|
+ 'access_translation_table_menu' => array(
|
|
|
|
+ 'title' => t('Access translation menu table')
|
|
|
|
+ ),
|
|
|
|
+ 'access_translation_table_taxonomy' => array(
|
|
|
|
+ 'title' => t('Access translation taxonomy table')
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ 'translate_strings' => array(
|
|
|
|
+ 'title' => t('Translate strings')
|
|
|
|
+ ),
|
|
|
|
+ 'delete_strings' => array(
|
|
|
|
+ 'title' => t('Delete strings')
|
|
|
|
+ ),
|
|
|
|
+ 'refresh_strings' => array(
|
|
|
|
+ 'title' => t('Refresh strings')
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ 'import_translations' => array(
|
|
|
|
+ 'title' => t('Import translations')
|
|
|
|
+ ),
|
|
|
|
+ 'export_translations' => array(
|
|
|
|
+ 'title' => t('Import translations')
|
|
|
|
+ ),
|
|
|
|
+ 'update_modules_translations' => array(
|
|
|
|
+ 'title' => t('Update modules translations')
|
|
|
|
+ ),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -113,25 +149,63 @@ function materio_translator_permission() {
|
|
* Implements hook_form_alter().
|
|
* Implements hook_form_alter().
|
|
*/
|
|
*/
|
|
function materio_translator_form_alter(&$form, &$form_state, $form_id) {
|
|
function materio_translator_form_alter(&$form, &$form_state, $form_id) {
|
|
- // Add materio_translator things to user/edit /user/add
|
|
|
|
- if ($form_id == 'user_register_form' || $form_id == 'user_profile_form' ) {
|
|
|
|
- // dsm($form_id, 'form_id');
|
|
|
|
- // dsm($form, 'form');
|
|
|
|
- // dsm($form_state, 'form_state');
|
|
|
|
-
|
|
|
|
- $form['materio_translator'] = array(
|
|
|
|
- '#type' => 'fieldset',
|
|
|
|
- '#title' => t('Translation access'),
|
|
|
|
- '#tree' => 0,
|
|
|
|
- '#access' => user_access('administer user translation language access'),
|
|
|
|
- );
|
|
|
|
- $form['materio_translator']['materio_translator'] = array(
|
|
|
|
- '#type' => 'checkboxes',
|
|
|
|
- '#options' => array(LANGUAGE_NONE => t('Language neutral')) + locale_language_list('name'),
|
|
|
|
- '#default_value' => materio_translator_load_permissions($form['#user']->uid),
|
|
|
|
- '#description' => t('The user get edit, delete access to all content which are in this enabled languages. Create, view access needs a different access level.'),
|
|
|
|
- );
|
|
|
|
|
|
+ // dsm($form_id);
|
|
|
|
+
|
|
|
|
+ // Add materio_translator things to user/edit /user/add
|
|
|
|
+ if ($form_id == 'user_register_form' || $form_id == 'user_profile_form' ) {
|
|
|
|
+ // dsm($form_id, 'form_id');
|
|
|
|
+ // dsm($form, 'form');
|
|
|
|
+ // dsm($form_state, 'form_state');
|
|
|
|
+
|
|
|
|
+ $form['materio_translator'] = array(
|
|
|
|
+ '#type' => 'fieldset',
|
|
|
|
+ '#title' => t('Translation access'),
|
|
|
|
+ '#tree' => 0,
|
|
|
|
+ '#access' => user_access('administer user translation language access'),
|
|
|
|
+ );
|
|
|
|
+ $form['materio_translator']['materio_translator'] = array(
|
|
|
|
+ '#type' => 'checkboxes',
|
|
|
|
+ '#options' => array(LANGUAGE_NONE => t('Language neutral')) + locale_language_list('name'),
|
|
|
|
+ '#default_value' => materio_translator_load_permissions($form['#user']->uid),
|
|
|
|
+ '#description' => t('The user get edit, delete access to all content which are in this enabled languages. Create, view access needs a different access level.'),
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // limit fields in string translation
|
|
|
|
+ if($form_id == 'i18n_string_locale_translate_edit_form'){
|
|
|
|
+ // dsm($form, 'form');
|
|
|
|
+ // dsm($form_state, 'form_state');
|
|
|
|
+ global $user;
|
|
|
|
+ $perms = materio_translator_load_permissions($user->uid);
|
|
|
|
+ // dsm($perms);
|
|
|
|
+ foreach ($form['translations'] as $langcode => $item) {
|
|
|
|
+ // disable field if langcode not in perms
|
|
|
|
+ if(!in_array($langcode, $perms) && isset($form['translations'][$langcode])){
|
|
|
|
+ $form['translations'][$langcode]['#disabled'] = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // limit fields in string translation
|
|
|
|
+ if($form_id == 'field_translation_table_form'
|
|
|
|
+ || $form_id == "node_translation_table_nodetype_form"
|
|
|
|
+ || $form_id == "menu_translation_table_menu_form"
|
|
|
|
+ || $form_id == "taxonomy_translation_table_taxonomy_form"){
|
|
|
|
+ // dsm($form, 'form');
|
|
|
|
+ // dsm($form_state, 'form_state');
|
|
|
|
+ global $user;
|
|
|
|
+ $perms = materio_translator_load_permissions($user->uid);
|
|
|
|
+ // dsm($perms);
|
|
|
|
+ foreach ($form['filtered_form']['strings'] as $id => $row) {
|
|
|
|
+ foreach ($row as $langcode => $field) {
|
|
|
|
+ // disable field if langcode not in perms
|
|
|
|
+ if(!in_array($langcode, $perms)){
|
|
|
|
+ $form['filtered_form']['strings'][$id][$langcode]['#disabled'] = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -224,10 +298,45 @@ function materio_translator_menu_alter(&$items) {
|
|
}
|
|
}
|
|
|
|
|
|
// translation add link
|
|
// translation add link
|
|
- if(preg_match('/^node\/%node\/edit\/add\/%entity_translation_language/', $path)){
|
|
|
|
|
|
+ // if(preg_match('/^node\/%node\/edit\/add\/%entity_translation_language/', $path)){
|
|
// dsm($item, $path);
|
|
// dsm($item, $path);
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
+ // translation add link
|
|
|
|
+ if(preg_match('/admin\/config\/regional\/translate/', $path)){
|
|
|
|
+ $items[$path]['access arguments'] = array('access_translations_overview');
|
|
|
|
+ }
|
|
|
|
+ if(preg_match('/admin\/config\/regional\/translate\/table/', $path)){
|
|
|
|
+ $items[$path]['access arguments'] = array('access_translation_table_fields');
|
|
}
|
|
}
|
|
|
|
+ if(preg_match('/admin\/config\/regional\/translate\/table\/nodetype/', $path)){
|
|
|
|
+ $items[$path]['access arguments'] = array('access_translation_table_content_type');
|
|
|
|
+ }
|
|
|
|
+ if(preg_match('/admin\/config\/regional\/translate\/table\/menu/', $path)){
|
|
|
|
+ $items[$path]['access arguments'] = array('access_translation_table_menu');
|
|
|
|
+ }
|
|
|
|
+ if(preg_match('/admin\/config\/regional\/translate\/table\/taxonomy/', $path)){
|
|
|
|
+ $items[$path]['access arguments'] = array('access_translation_table_taxonomy');
|
|
|
|
+ }
|
|
|
|
+ if(preg_match('/admin\/config\/regional\/translate\/translate/', $path)){
|
|
|
|
+ $items[$path]['access arguments'] = array('translate_strings');
|
|
|
|
+ }
|
|
|
|
+ if(preg_match('/admin\/config\/regional\/translate\/import/', $path)){
|
|
|
|
+ $items[$path]['access arguments'] = array('import_translations');
|
|
|
|
+ }
|
|
|
|
+ if(preg_match('/admin\/config\/regional\/translate\/i18n_string/', $path)){
|
|
|
|
+ $items[$path]['access arguments'] = array('refresh_strings');
|
|
|
|
+ }
|
|
|
|
+ if(preg_match('/admin\/config\/regional\/translate\/update/', $path)){
|
|
|
|
+ $items[$path]['access arguments'] = array('update_modules_translations');
|
|
|
|
+ }
|
|
|
|
+ if(preg_match('/admin\/config\/regional\/translate\/export/', $path)){
|
|
|
|
+ $items[$path]['access arguments'] = array('export_translations');
|
|
|
|
+ }
|
|
|
|
+ if(preg_match('/admin\/config\/regional\/translate\/delete/', $path)){
|
|
|
|
+ $items[$path]['access arguments'] += array("delete_strings");
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -430,7 +539,7 @@ function _materio_translator_form_node_form_alter($form, &$form_state) {
|
|
|
|
|
|
function materio_translator_node_tab_access(){
|
|
function materio_translator_node_tab_access(){
|
|
$args = func_get_args();
|
|
$args = func_get_args();
|
|
- dsm($args, '1 -- materio_translator_node_tab_access args');
|
|
|
|
|
|
+ // dsm($args, '1 -- materio_translator_node_tab_access args');
|
|
|
|
|
|
// dsm($entity_type, "entity_type");
|
|
// dsm($entity_type, "entity_type");
|
|
// dsm($entity, "entity");
|
|
// dsm($entity, "entity");
|