1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- /**
- * Implements hook_permission().
- */
- function materio_taxonomy_permission() {
- $perms = array();
- // foreach (taxonomy_get_vocabularies() as $voc) {
- // dsm($voc, '$voc');
- // // $perms['access taxonomy term page'] => array(
- // // 'title' => t(''),
- // // 'description' => t(''),
- // // );
- // }
- $perms['access taxonomy terms page'] = array(
- 'title' => t('access taxonomy terms page'),
- 'description' => t(''),
- );
- return $perms;
- }
- 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;
- }
- }
- }
- }
- }
|