|
@@ -0,0 +1,36 @@
|
|
|
+<?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;
|
|
|
+}
|