restrict page title on materiau node page for visitors

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy 2013-05-24 19:27:13 +02:00
parent ee27274830
commit 6c85be6c6d

View File

@ -19,18 +19,25 @@ function materio_title_access_permission() {
* Implements hook_field_access().
*/
function materio_title_access_field_access($op, $field, $entity_type, $entity, $account) {
/*
*if ($field['field_name'] == 'field_of_interest' && $op == 'edit') {
* return user_access('edit field of interest', $account);
*}
*/
/* Your code here */
// dsm($entity, 'entity');
// dsm($entity_type, 'entity_type');
if($field['field_name'] == 'title_field' && $entity_type == 'node' && isset($entity->type)){
return user_access('show '.$entity->type.' title');
}
return TRUE;
}
}
function materio_title_access_preprocess_html(&$vars){
if (arg(0) == 'node' && $node = node_load(arg(1))) {
if(!user_access('show '.$node->type.' title')){
if($node->type == "materiau"){
$title = field_get_items('node', $node, 'field_nature_titre');
$vars['head_title_array']['title'] = $title[0]['safe_value'];
}else{
$vars['head_title_array']['title'] = 'restricted access';
}
$vars['head_title'] = implode(' | ', $vars['head_title_array']);
}
}
}