fixed location field access for administrator, improved disbaled field display

This commit is contained in:
Bachir Soussi Chiadmi
2016-12-11 11:30:39 +01:00
parent 7ed9dc54bf
commit 8b5d721bfd
8 changed files with 1585 additions and 161 deletions

View File

@@ -198,7 +198,6 @@ function materio_showroom_field_widget_form(&$form, &$form_state, $field, $insta
'#default_value' => $showroom_tid,
// Allow a slightly larger size that the field length to allow for some
// configurations where all characters won't fit in input field.
'#size' => 10,
'#maxlength' => 255,
);
@@ -208,7 +207,7 @@ function materio_showroom_field_widget_form(&$form, &$form_state, $field, $insta
'#default_value' => $locval,
// Allow a slightly larger size that the field length to allow for some
// configurations where all characters won't fit in input field.
'#size' => 10,
'#size' => 20,
'#maxlength' => 255,
);
@@ -359,7 +358,8 @@ function _materio_showroom_alter_location_field_form(&$form, &$form_state, $form
foreach ($terms as $tid => $name) {
$item = $new_field_form[$field_name][LANGUAGE_NONE][$i];
$new_field_form[$field_name][LANGUAGE_NONE][$i]['location']['#title'] = $terms[$item['showroom_tid']['#default_value']];
$new_field_form[$field_name][LANGUAGE_NONE][$i]['location']['#disabled'] = !in_array($tid, $user_showrooms);
$disabled = !user_access('materio showroom edit all samples fields', $user) && !in_array($tid, $user_showrooms);
$new_field_form[$field_name][LANGUAGE_NONE][$i]['location']['#disabled'] = $disabled;
$i++;
}
@@ -376,13 +376,15 @@ function _materio_showroom_alter_location_field_form(&$form, &$form_state, $form
}
}
// TODO: migrate old location field to new one
/**
* Implements hook_permission().
*/
function materio_showroom_permission() {
return array(
'materio showroom edit all samples fields' => array(
'title' => t('Edit all materiO showroom samples fields'),
'description' => t('Edit all materiO showroom samples fields'),
),
'materio showroom migrate fields' => array(
'title' => t('Migrate materio showroom location fields'),
'description' => t('Migrate materio showroom location fields'),