<?php

// dsm($vars);

$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#view_mode'];
$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_type'] . '__' . $vars['element']['#view_mode'];
$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_name'] . '__' . $vars['element']['#view_mode'];


if($vars['element']['#field_name'] == 'field_materiau_image'){
	global $user;
	// dsm($vars);
	if( !isset($user->roles[10]) // student
    && !isset($user->roles[11]) // alphatesteur
    && !isset($user->roles[6]) // adherent
    && !isset($user->roles[8]) // premium
    && !isset($user->roles[12]) // translator
    && !isset($user->roles[13]) // admin showroom
    && !isset($user->roles[3]) // admin
    && !isset($user->roles[4]) // root
    && in_array($view_mode, $vm)){
		$items = $vars['items'];
		$vars['items'] = array($items[0]);
	}
}


# this does not work because of security probleme
# http://drupal.org/node/1923554
# http://drupal.stackexchange.com/questions/63226/drupal-7-20-image-styles-return-a-url-with-access-denied
// if($vars['element']['#field_type'] == 'text_with_summary'){
// 	foreach ($vars['items'] as $key => $value) {
// 		$text = $vars['items'][$key]['#markup'];
// 		parseImagesOntext($text);
// 		$vars['items'][$key]['#markup'] = $text;
// 	}
// }
