materio_title_access.module 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. // /**
  3. // * Implements hook_permission().
  4. // */
  5. // function materio_title_access_permission() {
  6. // $perms = array();
  7. // $entity_infos = entity_get_info();
  8. // foreach ($entity_infos['node']['bundles'] as $bundle => $value) {
  9. // $perms['show '.$bundle.' title'] = array(
  10. // 'title' => t('Show !bundle node title.', array('!bundle'=>$value['label'])),
  11. // );
  12. // }
  13. // return $perms;
  14. // }
  15. // /**
  16. // * Implements hook_field_access().
  17. // */
  18. // function materio_title_access_field_access($op, $field, $entity_type, $entity, $account) {
  19. // if($field['field_name'] == 'title_field' && $entity_type == 'node' && isset($entity->type)){
  20. // return user_access('show '.$entity->type.' title');
  21. // }
  22. // return TRUE;
  23. // }
  24. // function materio_title_access_preprocess_html(&$vars){
  25. // // dsm($vars, '$vars');
  26. // if (arg(0) == 'node' && $node = node_load(arg(1))) {
  27. // if(!user_access('show '.$node->type.' title')){
  28. // if($node->type == "materiau"){
  29. // $title = field_get_items('node', $node, 'field_nature_titre');
  30. // $vars['head_title_array']['title'] = $title[0]['safe_value'];
  31. // }else{
  32. // $vars['head_title_array']['title'] = 'restricted access';
  33. // }
  34. // $vars['head_title'] = implode(' | ', $vars['head_title_array']);
  35. // // dsm($vars, 'vars');
  36. // }
  37. // }
  38. // }