-
Notifications
You must be signed in to change notification settings - Fork 0
/
i18n_access.2337473.patch
34 lines (33 loc) · 1.22 KB
/
i18n_access.2337473.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff --git a/i18n_access.module b/i18n_access.module
index 5f4aa56..fd96042 100644
--- a/i18n_access.module
+++ b/i18n_access.module
@@ -103,20 +103,25 @@ function i18n_access_permission() {
* Implements hook_form_node_form_alter().
*/
function i18n_access_form_node_form_alter(&$form, &$form_state, $form_id) {
+ $form['#after_build'][] = '_i18n_access_form_node_form_alter';
+}
+
+function _i18n_access_form_node_form_alter($form, &$form_state) {
- if (isset($form['language']['#options'])) {
- // Remove inaccessible languages from the select box
+ if (isset($form['language']['#options']) && !user_access('bypass node access')) {
+ // Remove inaccessible languages from the select box
// don't do it for admininstrators
if (!user_access('administer nodes')) {
$perms = i18n_access_load_permissions();
+
foreach ($form['language']['#options'] as $key => $value) {
$perm_key = ($key == '') ? I18N_ACCESS_LANGUAGE_NEUTRAL : $key;
if ($key!='en' && empty($perms[$perm_key])) {
- unset($form['language']['#options']["$key"]);
+ unset($form['language']['#options'][$key]);
}
- }
+ }
}
- unset($form['#after_build']['0']);
}
+ return $form;
}