field.pre.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. // dsm($vars);
  3. $vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#view_mode'];
  4. $vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_type'] . '__' . $vars['element']['#view_mode'];
  5. $vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_name'] . '__' . $vars['element']['#view_mode'];
  6. if($vars['element']['#field_name'] == 'field_materiau_image'){
  7. global $user;
  8. // dsm($vars);
  9. if( !isset($user->roles[10]) // student
  10. && !isset($user->roles[11]) // alphatesteur
  11. && !isset($user->roles[6]) // adherent
  12. && !isset($user->roles[8]) // premium
  13. && !isset($user->roles[12]) // translator
  14. && !isset($user->roles[13]) // admin showroom
  15. && !isset($user->roles[3]) // admin
  16. && !isset($user->roles[4])){ // root
  17. // && in_array($view_mode, $vm)){
  18. $items = $vars['items'];
  19. $vars['items'] = array($items[0]);
  20. }
  21. }
  22. # this does not work because of security probleme
  23. # http://drupal.org/node/1923554
  24. # http://drupal.stackexchange.com/questions/63226/drupal-7-20-image-styles-return-a-url-with-access-denied
  25. // if($vars['element']['#field_type'] == 'text_with_summary'){
  26. // foreach ($vars['items'] as $key => $value) {
  27. // $text = $vars['items'][$key]['#markup'];
  28. // parseImagesOntext($text);
  29. // $vars['items'][$key]['#markup'] = $text;
  30. // }
  31. // }