materio-base-legacy/materio_title_access.module
bachy b750ae41c4 materio title access
Signed-off-by: bachy <git@g-u-i.net>
2012-10-30 18:09:14 +01:00

36 lines
919 B
Plaintext

<?php
/**
* Implements hook_permission().
*/
function materio_title_access_permission() {
$perms = array();
$entity_infos = entity_get_info();
foreach ($entity_infos['node']['bundles'] as $bundle => $value) {
$perms['show '.$bundle.' title'] = array(
'title' => t('Show !bundle node title.', array('!bundle'=>$value['label'])),
);
}
return $perms;
}
/**
* 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;
}