|  | @@ -1,4 +1,4 @@
 | 
	
		
			
				|  |  | -<?php	
 | 
	
		
			
				|  |  | +<?php
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * Implements hook_permission().
 | 
	
	
		
			
				|  | @@ -18,7 +18,7 @@ function materio_taxonomy_permission() {
 | 
	
		
			
				|  |  |      'title' => t('access taxonomy terms page'),
 | 
	
		
			
				|  |  |      'description' => t(''),
 | 
	
		
			
				|  |  |    );
 | 
	
		
			
				|  |  | -  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    return $perms;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -26,4 +26,52 @@ function materio_taxonomy_menu_alter(&$items) {
 | 
	
		
			
				|  |  |    $items['taxonomy/term/%taxonomy_term']['access arguments'] = array('access taxonomy terms page');
 | 
	
		
			
				|  |  |    $items['taxonomy/term/%taxonomy_term/view']['access arguments'] = array('access taxonomy terms page');
 | 
	
		
			
				|  |  |    $items['taxonomy/term/%taxonomy_term/feed']['access arguments'] = array('access taxonomy terms page');
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * Implementation of hook_query_term_access_alter().
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * debug de i18n_select_query_term_access_alter()
 | 
	
		
			
				|  |  | + * qui filtre les terms par language mm pour les vocabulaires en mode localized.
 | 
	
		
			
				|  |  | + * utile pour la recherche avancée de materio_search_api materio_search_api_advanced_search_form()
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +function materio_taxonomy_query_term_access_alter(QueryAlterableInterface $query) {
 | 
	
		
			
				|  |  | +  // dsm($query, 'materio taxo query');
 | 
	
		
			
				|  |  | +  $conditions =& $query->conditions();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  # roll over condition first time to determine i18n_voc_mode
 | 
	
		
			
				|  |  | +  $i18n_voc_mode = 0;
 | 
	
		
			
				|  |  | +  foreach ($conditions as $condition) {
 | 
	
		
			
				|  |  | +    if (is_array($condition)) {
 | 
	
		
			
				|  |  | +      // dsm($condition, 'conditon '.$condition['field']);
 | 
	
		
			
				|  |  | +      if($condition['field'] == 't.vid'){
 | 
	
		
			
				|  |  | +        $vid = $condition['value'];
 | 
	
		
			
				|  |  | +        $i18n_voc_mode = i18n_taxonomy_vocabulary_mode($vid);
 | 
	
		
			
				|  |  | +        // dsm($i18n_voc_mode, 'i18n_voc_mode');
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  # roll over conditions a second time to re-alter/fixe language selection
 | 
	
		
			
				|  |  | +  # i18n vocabulary mode is 1 for localized terms
 | 
	
		
			
				|  |  | +  if($i18n_voc_mode == 1){
 | 
	
		
			
				|  |  | +    foreach ($conditions as $index => $condition) {
 | 
	
		
			
				|  |  | +      if (is_array($condition)) {
 | 
	
		
			
				|  |  | +        // dsm($condition, 'conditon '.$condition['field']);
 | 
	
		
			
				|  |  | +        if($condition['field'] == 't.language' && $i18n_voc_mode == 1){
 | 
	
		
			
				|  |  | +          $l = array('und');
 | 
	
		
			
				|  |  | +          $ll = i18n_language_list();
 | 
	
		
			
				|  |  | +          // dsm($ll, 'list language');
 | 
	
		
			
				|  |  | +          foreach ($ll as $langcode => $langname) {
 | 
	
		
			
				|  |  | +            $l[] = $langcode;
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          $conditions[$index]['value'] = $l;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |